ちょっとすべて私のコードで、私はすべてのトピックのインデックスにリダイレクトしています。理論的には、ページにリダイレクトしたいと思います。
これが今の私はちょうどでスタンドとして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
' defを、私は、なぜ私はよく分からない
'@topics = Topic.all'
'認可(@topics) '
' end'
をindex'であなたの 'index'方法を共有することができますマークダウン構文が正しく機能していません。 – SinGar