Reputation: 110960
I have following from rake routes:
user GET /users/:id(.:format) {:action=>"show", :controller=>"users"}
But when I do, for an email template:
<%= link_to(@comment.user.full_name, user_url(:only_path => false), :style => 'color:#5196E3;text-decoration:underline;') %>
I get the following error: "ActionView::Template::Error (No route matches {:action=>"show", :controller=>"users"}):"
Thoughts? Thanks
Upvotes: 0
Views: 820
Reputation: 23307
This is sometimes confusing. Notice in your rake output, that the routing engine is expecting an id. if it doesn't get one, it doesn't recognize the route. Here's how you do it in controllers/views:
user_url(@comment.user)
or
user_url(@comment.user.id)
Upvotes: 1
Reputation: 21180
If you look at the route it needs an :id to parse. So you should supply the user like this:
user_url(@comment.user, :only_path => false)
Upvotes: 1