开发者

Devise destroy registration action to also destroy all authentications?

开发者 https://www.devze.com 2023-02-19 07:17 出处:网络
I\'m using DEvise for registration and omniauth for authentication through twitter/facebook, I want to destroy all authentications when a users destroys his account registration with Devise. What do I

I'm using DEvise for registration and omniauth for authentication through twitter/facebook, I want to destroy all authentications when a users destroys his account registration with Devise. What do I need to add to my registrations destroy method for this?

RegistrationsController < Devise::RegistrationsController

def destroy
  resource.destroy 
  set_flash_mes开发者_如何学Csage :notice, :destroyed
  sign_out_and_redirect(self.resource)
end


AuthenticationsController

def destroy
  @authentication = current_user.authentications.find(params[:id])
  @authentication.destroy
  flash[:notice] = "Successfully destroyed authentication."
  redirect_to authentications_url
end


I think you followed rbates on this one. The way he set it up was users having many authentications so correct me if I'm wrong.

You just need this:

class User < ActiveRecord::Base
    has_many :authentications, :dependent => :destroy
end 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号