How to get path in rails routes
I've seen calls to functions like
edit_person_path(person)
results_poll_path(poll)
But I can't replicate that to a path I've added
routes.rb
match 'proposals/:id/forkIt', :to => 'proposals#forkIt
And have forkIt_prop开发者_Python百科osal_path(proposal)
So, i wanted to know, how do I achieve that.
P.S.: I'm noob to Ruby, sorry.
You haven't set the route name. This should do the trick:
match 'proposals/:id/forkIt', :to => 'proposals#forkIt', :as => 'forkIt_proposal'
Or slightly more succinct:
match 'proposals/:id/forkIt' => 'proposals#forkIt', :as => 'forkIt_proposal'
you should have a look to http://guides.rubyonrails.org/routing.html#adding-more-restful-actions (section 2.9 "adding more restful actions".)
not sure of what i say (im a noob too) but i think that path helpers are only created when you declare restful routes with resources() (in your case, add an action on member)
Edit: actually, the guide do state that path helpers are created doing this.
精彩评论