lukaszkups
lukaszkups

Reputation: 5990

explicit get route is throwing an error

I defined a custom route:

match 'folio/:id' => 'posts#show', :as => :folio, :via => :get

When I run rake routes command I have:

post  GET    /posts/:id(.:format)     posts#show
folio GET    /folio/:id(.:format)     posts#show

And I put link for this element in my other page: link_to post.title, folio_path ,but when I enter it throws me an routing error:

No route matches {:controller=>"post", :action=>"show"}

Why it fails? When I'm using post#show in normal way it works like a charm, but with my custom route it fails - please help!

Upvotes: 0

Views: 55

Answers (1)

Baldrick
Baldrick

Reputation: 24340

You need to specify the post so rails can fill the id part:

link_to post.title, folio_path(post)

Upvotes: 1

Related Questions