Gibson
Gibson

Reputation: 2085

Devise not redirecting when user destroy session

I can't get Devise to refresh the page when user signing out. Session is being destroyed but I need to refresh the page in order to see the user logged out. I've tried setting turbolinks to false, and using remote: true, with no luck. Any ideas?

View

<li><%= link_to "Salir", destroy_user_session_path(current_user), class: "dropdown-item", :method => 'delete'   %></li>

Application Controller

 def after_sign_out_path_for(resource_or_scope)
   request.referrer
  end

Routes

devise_for :users, controllers: { registrations: "registrations" }

Logs

Started DELETE "/users/sign_out.91" for ::1 at 2021-05-16 14:22:54 +0200
Processing by Devise::SessionsController#destroy as 
  Parameters: {"authenticity_token"=>"VysuqONMdfsdfxA3cwH3UGliXGpjHVpE+Pxkk1eT7++S3fOQt5wyIJfuS90QrEVOMNxtYihSxQ/MMInkyypdeuC78Jw=="}
  User Load (0.3ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 91], ["LIMIT", 1]]
  ↳ /Users/x/.rvm/gems/ruby-2.7.2/gems/activerecord-5.2.4.4/lib/active_record/log_subscriber.rb:98
   (0.1ms)  BEGIN
  ↳ /Users/x/.rvm/gems/ruby-2.7.2/gems/activerecord-5.2.4.4/lib/active_record/log_subscriber.rb:98
   (0.2ms)  COMMIT
  ↳ /Users/x/.rvm/gems/ruby-2.7.2/gems/activerecord-5.2.4.4/lib/active_record/log_subscriber.rb:98
Completed 204 No Content in 4ms (ActiveRecord: 0.6ms)

Upvotes: 1

Views: 982

Answers (1)

Kamal Pandey
Kamal Pandey

Reputation: 1596

Update the link with

<li><%= link_to "Salir", destroy_user_session_path, class: "dropdown-item", :method => 'delete'   %></li>

Upvotes: 2

Related Questions