ubique
ubique

Reputation: 1212

Add a dynamic 'account' link?

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>

Upvotes: 0

Views: 87

Answers (1)

user483040
user483040

Reputation:

Just a shot in the dark...

update_user_registration_path

However...if you use

rake routes

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:

new_user_session GET    /logins/sign_in(.:format)  {:action=>"new", controller=>"devise/sessions"}

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...

Upvotes: 0

Related Questions