Reputation: 817
I have this route defined in my routes.rb:
matc "articles/:id/vote/up" => "articles#vote", :liked=>true
The rake for this route is:
/articles/:id/vote/up(.:format) jokes#vote {:liked=>true}
With the first column being blank. My question is, what would the route helper name be for this link? For example articles_vote_up_path(:id). Is there an uglier way to link to this path? How can I find out?
I'm thinking I misunderstood something, please guide me in the correct direction in that case.
Thank You
Upvotes: 0
Views: 176
Reputation: 29599
you need to pass an :as
option to use a named route
match "articles/:id/vote/up" => "articles#vote", :liked=>true, as: :article_vote_up
which generates an article_vote_up_path
Upvotes: 1
Reputation: 434
When you run rake routes
, you can add _path
to the whatever's in the first column on the left, and that's what the route url helper is for that link. For example, here's a line from rake routes
on one of my projects:
subscriptions GET /subscriptions(.:format) subscriptions#index
The url helper for this url would be subscriptions_path
.
Upvotes: 0