Alex Rivera | Logout

link_to() in Rails flash

Asked 2009-10-21T00:43:16.027
10

When a user fails login on my Rails app, I'd like to point them to a password reset page:

flash[:notice] = "Login failed.  If you have forgotten your password, you can #{link_to('reset it', reset_path)}"

However, I can't use link_to in a controller. What's the best way to do this without mixing controller and view logic?

My best guess is that the flash is the wrong place to do this, but I'd appreciate any input.

Edit
Report

1 Answer

5
flash[:notice] = "Login failed.  If you have forgotten your password, you can <a href='#{url_for(reset_path)}'>reset it</a>"

Correct, link_to is a view helper. Please us a more generic way of building the link, à la url_for

answered 2009-10-21T05:07:39.207

Your Answer