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?
Try adding a new route to devise/sessions#destroy and linking to that. Eg:
view:
If you're using HTTPS with devise, it'll break if your sign-out link is to the non-secure version. On the back end, it redirects to the secure version. That redirect is a GET, which causes the issue.
Make sure your link uses HTTPS. You can force it with
protocol: "https"
in your url helper (make sure you use the url helper and not the path helper).This is what I did (with Rails 3.0 and Devise 1.4.2):
Don't forget to include the following line in your application.js (Rails 3)
Include
jquery_ujs
into my rails application and it works now.The problem begin with rails 3.1... in
/app/assets/javascript/
just look for application.js.If the file doesn't exist create a file with that name I don't know why my file disappear or never was created on
"rails new app"...
.That file is the instance for
jquery...
.In general when you get "No route matches" but you think you have that route defined then double check the http verb / request method (whether its get, put, post, delete etc.) for that route.
If you run rake routes then you will see the expected method and you can compare this with the request log.