Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveAdmin and Devise - skip_confirmation! on create action

I want to call user.skip_confirmation while his account is created by admin in admin panel. I want user to confirm his account in further steps of registration process, but not on create. The only idea I have is to override create in controller:

controller do
  def create
    user = User.new
    user.skip_confirmation!
    user.confirmed_at = nil
    user.save!
  end
end

The problem is, I have different attr_accessibles for standard user and admin, and it works, because ActiveAdmin uses InheritedResources:

attr_accessible :name, :surname
attr_accessible :name, :surname, invitation_token, :as => :admin

It doesn't work after I changed create (it worked before). How can I do what I want and still be able to use this :as => :admin feature?

like image 795
ciembor Avatar asked Feb 19 '26 23:02

ciembor


1 Answers

I look at the answer and none is solving the issue at hand. I solve it the simplest way as shown below.

before_create do |user|
 user.skip_confirmation!
end
like image 124
Cedric Loy Avatar answered Feb 21 '26 14:02

Cedric Loy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!