Given the following resource definition:
map.resources :posts, :except => [:show]
map.post '/:year/:month/:slug, :controller => :posts, :action => :show
I can make url_for
work for me, using this syntax:
<%= link_to @post.title, post_url(:year => '2010', :month => '02', :slug => 'test') %>
But is there a way to make this work?
<%= link_to @post.title, @post %>
Currently it throws this error:
No route matches {:year=>#<Post id: 1, title: "test", (...)>, :controller=>"posts", :action=>"show"}
Apparently it passes the @post object to the first route parameter (seems like a Rails bug...). But can I make this work for me? I'll add that messing with default_url_options
is a dead end.
Solution working only in Rails 3.x is ok, but I would prefer not to use any plugins.