I am learning Ruby on Rails and I have a dumb question about the link_to function.
I set up a controller called “home” and I’ve created “index” as an action .
I’ve set up devise. However, when I browse to some links like sign_in, sign_up, etc. I get this error:
Routing Error
No route matches {:controller=>"devise/home"}
I’ve narrowed it down to:
<%= link_to "Home", { :controller => "home", :action => "index" }, :class => "navlink" %>
This works for my actions for home but not for my devise actions.
What am I missing here?
Devise creates a set of helper functions for you that generate the correct paths. Run
rake routesfrom the command line to see them. You’ll get output similar to the following (assuming your Devise model is calledUser).Appending
_pathto the first part of each line gives you the name of the helper function you need to call.For example, the following would give you a link to the login page:
Remember if the request is a
DELETErather than aGET(such as the logout link) you’ll need to specify this as part of the call tolink_to.