我刚刚在我的rails应用程序中添加了活动管理员,但我无法创建新用户。我使用active admin创建的用户模型,并添加了一些列,如名字和姓氏。当我为新用户填写表单并单击create new user时,该页面会刷新,但不会保存我的用户,也不会转到recap页面并显示成功消息。
这是我的AdminUser模型
class AdminUser < ActiveRecord::Base
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name
end这是我的活动管理类
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发布于 2011-12-02 04:24:56
忘记将这个小家伙添加到model...fml
after_create { |admin| admin.send_reset_password_instructions }
def password_required?
new_record? ? false : super
end发布于 2013-12-17 04:07:18
我的解决方案是:
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发布于 2011-12-01 19:36:53
这与Rails中的代码重载错误有关,该错误在您的环境指定config.cache_classes = false时表现出来。
在config/environments/development.rb中将其更改为true,重新启动服务器,您就应该能够创建用户了。
但是,这并不理想,一种变通方法是在config/environments/development.rb中添加以下内容
config.to_prepare do
Thread.current.keys.each{ |k| Thread.current[k] = nil if k.to_s =~ /_scoped_methods$/ }
end虽然bug似乎已经解决了,但我在3.1.1中看到了上面的代码修复的问题。
尽管这是Rails中的一个bug,但如果您想查看有关这方面的更多讨论,也会将其记录为bug in active_admin。
https://stackoverflow.com/questions/8126747
复制相似问题