我有Ruby on Rails 4应用程序,我也使用Devise gem来提供登录/注册。
一切正常,但登录的用户无法删除自己的帐户。任何其他删除功能都有效,所以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
他也从他的帐户退出,但实际的破坏从未发生过。可能有什么问题?
感谢您的时间。 祝福。
答案 0 :(得分:1)
此处Destroy
使用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查询)。