If you run rake routes
, you'll probably get a line in the output that reads like this:
vote_up_book_comment POST /:book_id/comments/:id/vote_up(.:format) comments#vote_up
Pay special attention to this part — it's telling you what the vote_up_book_comment_path
method expects as arguments:
/:book_id/comments/:id/vote_up(.:format)
Also, your error message is giving you a few hints:
No route matches ...
:id=>nil, :book_id=>#<Comment id: 3 ...
missing required keys: [:id]
The path helper expects an id (for the comment) and a book_id, and the order in which they are required is shown in rake routes
(book_id first, then id).
So, in sum, you need to pass a book
to vote_up_book_comment_path
:
<%= link_to('vote for this post!', vote_up_book_comment_path(@book, comment), :method => :post) %>