next comment
按钮应指向http://localhost:3000/articles/14/comments/70
。Ruby on Rails:控制器未评估方法
它目前执行的是: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
UPDATE
#routes.rb
resources :articles do
resources :comments do
member do
get 'next_comment'
end
end
end
你可以更新'routes.rb'代码的问题? – Pavan
完成!谢谢... – Liroy
任何线索是怎么回事? – Liroy