当用户销毁会话时设计不重定向
Devise not redirecting when user destroy session
我无法让 Devise 在用户注销时刷新页面。会话正在被销毁,但我需要刷新页面才能看到用户已注销。我试过将 turbolinks 设置为 false,并使用 remote: true,但没有成功。有什么想法吗?
查看
<li><%= link_to "Salir", destroy_user_session_path(current_user), class: "dropdown-item", :method => 'delete' %></li>
应用程序控制器
def after_sign_out_path_for(resource_or_scope)
request.referrer
end
路线
devise_for :users, controllers: { registrations: "registrations" }
日志
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" = ORDER BY "users"."id" ASC LIMIT [["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)
将 link 更新为
<li><%= link_to "Salir", destroy_user_session_path, class: "dropdown-item", :method => 'delete' %></li>
我无法让 Devise 在用户注销时刷新页面。会话正在被销毁,但我需要刷新页面才能看到用户已注销。我试过将 turbolinks 设置为 false,并使用 remote: true,但没有成功。有什么想法吗?
查看
<li><%= link_to "Salir", destroy_user_session_path(current_user), class: "dropdown-item", :method => 'delete' %></li>
应用程序控制器
def after_sign_out_path_for(resource_or_scope)
request.referrer
end
路线
devise_for :users, controllers: { registrations: "registrations" }
日志
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" = ORDER BY "users"."id" ASC LIMIT [["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)
将 link 更新为
<li><%= link_to "Salir", destroy_user_session_path, class: "dropdown-item", :method => 'delete' %></li>