0
안녕하세요. 모든 코드에서 모든 주제의 색인으로 다시 리디렉션되고 이론적으로 페이지로 다시 리디렉션하고 싶습니다.
이 바로 지금은 그냥 스탠드로 topics_path
을 사용하고,이 페이지에 대한 내 컨트롤러입니다.내 주제/쇼 페이지로 리디렉션하는 방법은 무엇입니까?
class LikesController < ApplicationController
def index
end
def create
@bookmark = Bookmark.find(params[:bookmark_id])
like = current_user.likes.build(bookmark: @bookmark)
if like.save
flash[:notice] = "Successfully liked bookmark."
else
flash.now[:alert] = 'Error in liking bookmark. Please try again.'
end
redirect_to topics_path
end
def destroy
@bookmark = Bookmark.find(params[:bookmark_id])
like = current_user.likes.find(params[:id])
# Get the bookmark from the params
# Find the current user's like with the ID in the params
if like.destroy
flash[:notice] = "Successfully unliked bookmark."
else
flash.now[:alert] = 'Error in unliking bookmark. Please try again.'
end
redirect_to topics_path
end
end
이 내가 redirect_to
bookmarks_show GET /bookmarks/show(.:format) bookmarks#show
당신이 TopicsController' – SpunkyLive
'에서'index' 방법을 공유 할 수'데프
'@topics = Topic.all'
'인증 (@topics를) index''
는'잘 모르겠어요
end' 왜 내 markdown 구문이 제대로 작동하지 않습니다. – SinGar