Updating Passwords and Emails When Using Active Admin and Devise
With Active Admin and Devise, we want to: * Skip email confirmations * Require password and email confirmations, but only when changing the email or password
This code supports our requirements:
ActiveAdmin.register User do
controller do
def update
if params[:user][:password].blank?
params[:user].delete("password")
params[:user].delete("password_confirmation")
end
if params[:user][:email].blank?
params[:user].delete("email")
params[:user].delete("email_confirmation")
end
super
end
end
before_save do |user|
user.skip_confirmation!
user.skip_reconfirmation!
end
end