在 ActiveAdmin 1.0.0 中路由到控制器

Routing to Controller in ActiveAdmin 1.0.0

rake routes 给出输出

POST    /admin/users(.:format)    admin/users/new

但是new动作是在哪里执行的呢? /admin/user 是注册的资源。没有任何动作。但是,通过标准 AA 表单创建新用户会将我的用户放入数据库中,但使用哪个控制器?

更新:

我想使用带有密码的 ActiveAdmin 创建一个新用户,并使用设计存储散列密码。新操作适用于我通过 rails 控制台

测试的普通用户控制器
@user=User.create(params.permit(:name, :phone, :active, :password_digest
@user.password = Devise.friendly_token

到目前为止,我在 AA user.rb 资源中破解了这样的操作:(基本上相同的语句封装在 controller do...)

controller do
  def new 
@user.password = Devise.friendly_token
    @user=User.create(params.permit(:name, :phone, :active, :password_digest

我现在遇到的问题是,用户已保存在我的数据库中,但使用的是未经加密的密码。(?) live demo and the documentation 关于此问题的详细信息或示例有点短。

ActiveAdmin Gem 根据您的配置 admin/user.rb

即时创建一个 Admin::UsersController

ActiveAdmin 使用 inherited resources gem 作为默认控制器操作。如果你想覆盖 new 控制器操作,你可以像这样在你的 activeadmin 资源代码中覆盖它:

ActiveAdmin.register User do
  controller do
    def new
      super #use the default methods and response block
      @user.activate! #if you want to add some methods
    end
  end
end