The next comment
button should be directed to http://localhost:3000/articles/14/comments/70
.
What it currently executes is: 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
#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)
And try whith: article_comment_next_comment_path(@article, @comment)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.