mardi 26 mai 2015

User can't delete his own account , Rails 4 + Devise

I have Ruby on Rails 4 application also I am using Devise gem to provide login/register.

Everything works just fine, but users that are logged in can't delete their own account. Any other delete functions work, so Javascript shouldn't be a problem.

In view:

  <%= link_to "Delete account", registration_path(resource_name), data: { confirm: "Your profile will be permanently deleted. Are you sure?" }, method: :delete%>

I am overriding default devise Registration controller with this:

class RegistrationsController < Devise::RegistrationsController 
    clear_respond_to   
    respond_to :json

    protected

  def update_resource(resource, params)
    resource.update_without_password(params)
  end
end

My log file:

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://ift.tt/1AseAWL
Completed 302 Found in 24ms (ActiveRecord: 4.4ms)

Description:

When user pushes delete button, user gets message :

translation missing: ru.devise.registrations.user.destroyed

also he is logged out from his account, but the actual destroying never happens. What could be possible problem?

Thanks for your time. Best wishes.

Aucun commentaire:

Enregistrer un commentaire