rails 3 named routes
I am upgrading my application to rails 3. My old route was
map.profile 'profile/:login', :controller => 'profile', :action => 'show'
I changed this to:
match 'profile/:login', :to => 'profile#show'
This works 开发者_如何学Pythonwhen I enter in the route say /profile/red99
But when I use a generic link like:
<%= link_to image.user.login, :controller => "profile", :action => image.user.login %>
or
<%= link_to "public profile", :controller => "profile", :action => current_user.login %>
I gives me the error No route matches {:controller=>"profile", :action=>"red99"}
If you want to specify the URL for the profile you still need to use the parameters:
:controller => 'profile', :action => 'show', :login => current_user.login
You haven't changed the action
parameter by defining that route, you've simply made a more readable URL by implicitly specifying the action.
精彩评论