next comment
按钮应指向http://localhost:3000/articles/14/comments/70
。
目前执行的是:http://localhost:3000/articles/14/comments/56/next_comment
如何解决这个问题?
#button
= link_to "next comment", next_comment_article_comment_path(@article, @comment)
#controller
class CommentsController < ApplicationController
def next_comment
@comment ||= @scope.next(@comment)
end
def scope
@scope ||= @article.comments
end
end
更新
#routes.rb
resources :articles do
resources :comments do
member do
get 'next_comment'
end
end
end
答案 0 :(得分:0)
运行rake routes
并检查是否有到next_comment_article_comment_path(@article, @comment)
尝试whith:article_comment_next_comment_path(@article, @comment)