Rails url_for not finding the route which appears in Rake Routes?

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

Answers


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)

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)

Need Your Help

Apply the configuration of the app for each activity

java android configuration android-activity

How can I apply the configuration chosen by the user, in each activty of the app, without to rewrite the code in each of them?

How to Disable IBAction Button, that is on subView

ios objective-c uibutton ibaction

i have an IBAction button that is connected through connection inspector properly…

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.