Unable to create a new user using ActiveAdmin

I just added an active admin to my rails application and I cannot create a new user. I am using the user model that the active administrator creates, with several columns added, such as first name and last name. When I fill out a form for a new user and click on create a new user, this page is updated, but does not save my user and does not go to the page with a successful message.

here is my adminminer model

class AdminUser < ActiveRecord::Base devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name end 

And here is my active admin class

 ActiveAdmin.register AdminUser do index do column :first_name column :last_name column :email default_actions end form do |f| f.inputs "User Details" do f.inputs :email f.inputs :first_name f.inputs :last_name end f.buttons end end 
+1
ruby-on-rails-3 devise activeadmin
Nov 14 '11 at 19:08
source share
4 answers

Forgot to add this little guy to the model ... fml

 after_create { |admin| admin.send_reset_password_instructions } def password_required? new_record? ? false : super end 
+3
Dec 01 '11 at 20:24
source share

My decision:

 ActiveAdmin.register User do permit_params [:email, :password, :password_confirmation] form do |f| f.inputs "User" do f.input :email f.input :password f.input :password_confirmation end f.actions end end 
+7
Dec 16 '13 at 20:07
source share

This is due to a code reload error in Rails that occurs when your environment points to config.cache_classes = false .

Change this to true in config/environments/development.rb , restart the server and you can create your user.

However, which is not ideal, and one workaround proposed here is to put the following in your config/environments/development.rb :

  config.to_prepare do Thread.current.keys.each{ |k| Thread.current[k] = nil if k.to_s =~ /_scoped_methods$/ } end 

Although the error seems to be resolved, I see the problem in 3.1.1, which is fixed above.

Although this is a bug in Rails, it is also logged as a bug in active_admin if you want to discuss this more.

+2
Dec 01 2018-11-11T00:
source share

Activate @Danpe's answer. Password is a required field. Therefore, you need to add it to allow_params and also request a password in the form. Only then will he save the form correctly. Here is my param params line, which also fixes other issues when creating the ActiveAdmin user mentioned here: https://github.com/gregbell/active_admin/issues/2595

 controller do def permitted_params params.permit :utf8, :_method, :authenticity_token, :commit, :id, model: [:attribute1, :attribute2, etc] end end 
0
Jan 22 '14 at 17:48
source share



All Articles