I have a Rails app using devise and login/logout works fine live but I can't seem to logout or login on localhost.
I had changed session_store.rb so that sessions would be shared across subdomains:
Rails.application.config.session_store :cookie_store, key: '_myapp_session', domain: :all, tld_length: 2
Can you see anything that would be preventing me from logging out and logging in locally?
in config/routes:
as :user do
get 'login' => 'sessions#new', :as => :new_user_session
post 'login' => 'sessions#create', :as => :user_session
delete 'logout' => 'sessions#destroy', :as => :destroy_user_session
end
in view:
<li><%= link_to 'Logout', destroy_user_session_path, method: :delete %></li>
<% else %>
<li><%= link_to 'Login', new_user_session_path %></li>
<li><%= link_to 'Signup', "#", :class => "modal-link", :data=>{toggle: "modal", target: "#myModal"} %></li>
I've the same configuration here and my logout works fine.
Check if you logout button has the method: :delete
as an option.
eg:
link_to 'Logout', destroy_user_session_path, method: :delete
Once I had this problem and realize I didn't have this line:
//= require jquery_ujs
on my application.js
(or any other JS file my page require)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.