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!
You need to specify the post so rails can fill the id
part:
link_to post.title, folio_path(post)