I've installed devise on my app and applied the following in my application.html.erb
file:
<div id="user_nav">
<% if user_signed_in? %>
Signed in as <%= current_user.email %>. This cannot be cheese?
<%= 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 %>
</div>
I ran rake routes
and confirmed that all the routes are valid.
Also, in my routes.rb
file I have devise_for :users
and root :to => "home#index"
.
I get the following routing error when clicking the "Sign out" link:
No route matches "/users/sign_out"
Any ideas what's causing the error?
You probably didn't include jquery_ujs javascript file. Make sure you are using the latest version of jquery-ujs : https://github.com/rails/jquery-ujs and the last files available :
You should not have any more rails.js file. If you do, you're probably out-of-date. Make sure also this file is loaded with defaults, in config/application.rb
(Again, you should not have rails.js file here). Finally, add the link as documented on Devise wiki (haml-style):
And everything will be fine.
In your routes.rb :
and in your application.html.erb:
With one exception, Jessie's answer worked for me:
change:
... to:
So the code that worked for me is:
I changed this line in devise.rb:
to
and it started working for me.
Well, guys for me it was only remove the :method => :delete