Pier-Olivier Thibault
Pier-Olivier Thibault

Reputation: 3927

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 works as expected, I just want to use the proper methods

Upvotes: 2

Views: 601

Answers (1)

Brett Bender
Brett Bender

Reputation: 19749

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.

Upvotes: 1

Related Questions