Topic: devise logout

I have been trying to use devise to keep track of users but i have a problem when i try to logout

<% if user_signed_in? %>
  Signed in as <%= current_user.email %>.
  <%= link_to 'Sign out', destroy_user_session_path %>
<% else %>
  <%= link_to 'Register', new_user_registration_path %> or <%= link_to 'Sign in', new_user_session_path %>
<% end %>

BUT when i click the Sign out link i go to http://localhost:3000/users/sign_out with a error

Routing Error

No route matches [GET] "/users/sign_out"

Try running rake routes for more information on available routes.

rake routes

new_user_session GET    /users/sign_in(.:format)                    devise/sessions#new
                         POST   /users/sign_in(.:format)                    devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)                   devise/sessions#destroy
                         POST   /users/password(.:format)                   devise/passwords#create
                         GET    /users/password/new(.:format)               devise/passwords#new
                         GET    /users/password/edit(.:format)              devise/passwords#edit
                         PUT    /users/password(.:format)                   devise/passwords#update
                         GET    /users/cancel(.:format)                     devise/registrations#cancel
                         POST   /users(.:format)                            devise/registrations#create
                         GET    /users/sign_up(.:format)                    devise/registrations#new
                         GET    /users/edit(.:format)                       devise/registrations#edit
                         PUT    /users(.:format)                            devise/registrations#update
                         DELETE /users(.:format)                            devise/registrations#destroy

Re: devise logout

Look at this: http://stackoverflow.com/questions/6557 … se-rails-3

Re: devise logout

Thanks that helps

but i just started a brand new project
with devise.

but when i go to http://localhost:3000/user/sign_in

i cant see the link to create account and forgot password.


does any one know how i get those links

Re: devise logout

Hey Moises,

If you generated your devise views and looked at _links.html.erb (Where the sign_up and forgotten password links live), it'd look something like this:

  <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
    <li><%= link_to "Sign up", new_registration_path(resource_name) %></li>
  <% end -%>

  <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
    <li><%= link_to "Forgot your password?", new_password_path(resource_name) %></li>
  <% end -%>

The key is registerable? and recoverable?. These options need to be in your User model like so:

 devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

If you have those, and it's still not showing up, show us the code you are using for the links. There might be something wrong with that.

Change is a vector. You can have all the change in the world, but if it doesn't go in the right direction, what good is it? | techonamission.com

Re: devise logout

Thanks you