用户无法删除自己的帐户,Rails 4 + 设计
User can't delete his own account , Rails 4 + Devise
我在 Rails 4 应用程序上有 Ruby 我也在使用 Devise gem 来提供 login/register。
一切正常,但登录的用户无法删除自己的帐户。任何其他删除功能都可以使用,所以 Javascript 应该不是问题。
在视图中:
<%= link_to "Delete account", registration_path(resource_name), data: { confirm: "Your profile will be permanently deleted. Are you sure?" }, method: :delete%>
我正在覆盖默认设计注册控制器:
class RegistrationsController < Devise::RegistrationsController
clear_respond_to
respond_to :json
protected
def update_resource(resource, params)
resource.update_without_password(params)
end
end
我的日志文件:
Started DELETE "/ru/users" for xx.xxx.xxxx.xx at 2015-05-26 22:30:45 +0300
Processing by RegistrationsController#destroy as HTML
Parameters: {"authenticity_token"=>"dXKjMMmKibIy2LNCrR66JuThjPzqsdtjFMXTCubcFe8=", "locale"=>"ru"}
[1m[36mUser Load (0.3ms)[0m [1mSELECT `users`.* FROM `users` WHERE `users`.`id` = 66 ORDER BY `users`.`id` ASC LIMIT 1[0m
[1m[35mCountry Load (0.3ms)[0m SELECT `countries`.* FROM `countries` WHERE `countries`.`id` = 1 LIMIT 1
[1m[36m (0.6ms)[0m [1mSELECT COUNT(*) FROM `girls` WHERE (country_id=1) AND (vip_recomend >= '2015-05-26 22:30:45')[0m
[1m[35m (0.4ms)[0m SELECT COUNT(*) FROM `girls` WHERE (country_id=1) AND (recomend >= '2015-05-26 22:30:45')
[1m[36m (0.3ms)[0m [1mSELECT COUNT(*) FROM `girls` WHERE (country_id=1) AND (highlight >= '2015-05-26 22:30:45')[0m
[1m[35m (0.3ms)[0m SELECT COUNT(*) FROM `girls` WHERE (country_id=1) AND (vip_highlight >= '2015-05-26 22:30:45')
[1m[36mRegion Load (0.2ms)[0m [1mSELECT `regions`.* FROM `regions` WHERE `regions`.`country_id` = 1[0m
[1m[35mList Load (0.3ms)[0m SELECT `lists`.* FROM `lists` WHERE (billing_id =5) ORDER BY `lists`.`id` ASC LIMIT 1
[1m[36m (0.3ms)[0m [1mBEGIN[0m
[1m[35m (0.2ms)[0m COMMIT
[1m[36m (0.2ms)[0m [1mBEGIN[0m
[1m[35m (0.2ms)[0m COMMIT
Redirected to http://xxxxxxxxxxx.xxx.xxx/ru
Completed 302 Found in 24ms (ActiveRecord: 4.4ms)
描述:
当用户按下删除按钮时,用户收到消息:
translation missing: ru.devise.registrations.user.destroyed
他也从他的帐户中注销了,但是真正的销毁从未发生过。可能是什么问题?
感谢您的宝贵时间。
祝福。
此处Destroy
使用设计registrations_controller的destroy
方法删除用户帐号。对于 translation missing: ru.devise.registrations.user.destroyed
,您需要在 devise.ru.yml 文件中进行更改 -
ru:
devise:
registrations:
user:
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
这是后台进程。因此,您无法在日志中看到(删除 sql 查询)。
我在 Rails 4 应用程序上有 Ruby 我也在使用 Devise gem 来提供 login/register。
一切正常,但登录的用户无法删除自己的帐户。任何其他删除功能都可以使用,所以 Javascript 应该不是问题。
在视图中:
<%= link_to "Delete account", registration_path(resource_name), data: { confirm: "Your profile will be permanently deleted. Are you sure?" }, method: :delete%>
我正在覆盖默认设计注册控制器:
class RegistrationsController < Devise::RegistrationsController
clear_respond_to
respond_to :json
protected
def update_resource(resource, params)
resource.update_without_password(params)
end
end
我的日志文件:
Started DELETE "/ru/users" for xx.xxx.xxxx.xx at 2015-05-26 22:30:45 +0300
Processing by RegistrationsController#destroy as HTML
Parameters: {"authenticity_token"=>"dXKjMMmKibIy2LNCrR66JuThjPzqsdtjFMXTCubcFe8=", "locale"=>"ru"}
[1m[36mUser Load (0.3ms)[0m [1mSELECT `users`.* FROM `users` WHERE `users`.`id` = 66 ORDER BY `users`.`id` ASC LIMIT 1[0m
[1m[35mCountry Load (0.3ms)[0m SELECT `countries`.* FROM `countries` WHERE `countries`.`id` = 1 LIMIT 1
[1m[36m (0.6ms)[0m [1mSELECT COUNT(*) FROM `girls` WHERE (country_id=1) AND (vip_recomend >= '2015-05-26 22:30:45')[0m
[1m[35m (0.4ms)[0m SELECT COUNT(*) FROM `girls` WHERE (country_id=1) AND (recomend >= '2015-05-26 22:30:45')
[1m[36m (0.3ms)[0m [1mSELECT COUNT(*) FROM `girls` WHERE (country_id=1) AND (highlight >= '2015-05-26 22:30:45')[0m
[1m[35m (0.3ms)[0m SELECT COUNT(*) FROM `girls` WHERE (country_id=1) AND (vip_highlight >= '2015-05-26 22:30:45')
[1m[36mRegion Load (0.2ms)[0m [1mSELECT `regions`.* FROM `regions` WHERE `regions`.`country_id` = 1[0m
[1m[35mList Load (0.3ms)[0m SELECT `lists`.* FROM `lists` WHERE (billing_id =5) ORDER BY `lists`.`id` ASC LIMIT 1
[1m[36m (0.3ms)[0m [1mBEGIN[0m
[1m[35m (0.2ms)[0m COMMIT
[1m[36m (0.2ms)[0m [1mBEGIN[0m
[1m[35m (0.2ms)[0m COMMIT
Redirected to http://xxxxxxxxxxx.xxx.xxx/ru
Completed 302 Found in 24ms (ActiveRecord: 4.4ms)
描述:
当用户按下删除按钮时,用户收到消息:
translation missing: ru.devise.registrations.user.destroyed
他也从他的帐户中注销了,但是真正的销毁从未发生过。可能是什么问题?
感谢您的宝贵时间。 祝福。
此处Destroy
使用设计registrations_controller的destroy
方法删除用户帐号。对于 translation missing: ru.devise.registrations.user.destroyed
,您需要在 devise.ru.yml 文件中进行更改 -
ru:
devise:
registrations:
user:
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
这是后台进程。因此,您无法在日志中看到(删除 sql 查询)。