Am using the Devise plugin for user sign-in. I want to to display an ‘edit’ link to the user in this code block so it only displays to users who are logged in so they can change their account password and email address. How do I do it within this code block?
The rake route is: /users/edit(.:format) {:controller=>"devise/registrations", :action=>"edit"}
<div id="user_nav">
<%= link_to "Home | ", root_path %>
<% if user_signed_in? %>
Signed in as . Not you?
<%= link_to "Sign Out", destroy_user_session_path %>
<% else %>
<%= link_to "Sign Up", new_user_registration_path %> or
<%= link_to "Sign In", new_user_session_path %>
<% end %>
</div>
Just a shot in the dark…
However…if you use
you’ll get a list of valid routes and the string that leads off the output + the string “_path” after it should map to what you want.
On our app we’ve disabled the devise/registrations controller so I can’t just check for you or I would have done that :/ But here is the line of output from rake routes for one of the session ones:
In this case, the string of interest is “new_user_session”. Add _path and you wind up with the method you used in your example to log in…