Nested route with :member
I'm using rails3 and I have the following bit in my routing.rb:
resources :questions do
resources :answers do
get 'accept', :on => :member
end
end
Now I'm trying to find how to use the auto-generated routing method.
I've used many variations of
questions_accepts_answers_path(@question,answer)
but none have worked yet.
As a side note, I am currently using
<%= link_to "Accept this answer", "/question/#{question.id}/answers/#{answer.id}/accept" %>
and the routing 开发者_如何学Goworks as expected, I just want to use the proper methods
Have you tried running rake routes
from the command line (in the default directory of your rails app)? It will give you a list of all the generated route helpers and their associated paths. From this, it should be easy to figure out which path helper you are looking for. If you are looking for a specific path, you may want to do something like rake routes | grep question
or rake routes | grep answer
.
精彩评论