I'm a bit confused about how devise is routing my requests, for some reason I can't go to the sign-out path in my app now:
ActionController::RoutingError (No route matches [GET] "/users/sign_out")
Here is what my routes related to my User model and Devise look like:
devise_for :users, :controllers => {:registrations => "registrations"}
devise_scope :user do
get '/settings' => 'registrations#edit'
end
Would defining that scope prevent my other routes from working as well?
Update
I don't think that it's supposed to be GET
request, as my link looks like:
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
If you try to go to /users/sign_out by typing it in the address bar of your browser, or linking to it normally, you will get this error. To summarize some comments and answers here and from issues at the devise repo on github:
This is the intended functionality, RESTful apps should not modify state with a GET request.
You can fix this by making a link that uses the DELETE method as mentioned by @Trip, @fuzzyalej, and the update by @Joseph Silvashy.
Alternatively, (and less recommended), in /config/initializers/devise.rb, you could make the following change
config.sign_out_via = :delete
to
config.sign_out_via = :get
I came across this issue while following along with http://railscasts.com/episodes/209-introducing-devise and with the older version of devise he's using there, this was not an issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With