[英]Ruby on Rails: Controller Not Evaluating Method
The next comment
button should be directed to http://localhost:3000/articles/14/comments/70
. next comment
按钮应指向http://localhost:3000/articles/14/comments/70
。
What it currently executes is: http://localhost:3000/articles/14/comments/56/next_comment
它当前执行的是: http://localhost:3000/articles/14/comments/56/next_comment
How does one fix this? 如何解决这个问题?
#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 UPDATE
#routes.rb
resources :articles do
resources :comments do
member do
get 'next_comment'
end
end
end
Run rake routes
and check if there is a route to next_comment_article_comment_path(@article, @comment)
运行rake routes
,检查是否有通往next_comment_article_comment_path(@article, @comment)
的路线
And try whith: article_comment_next_comment_path(@article, @comment)
并尝试以下方式: article_comment_next_comment_path(@article, @comment)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.