我使用了Rails5
和activeadmin
,并且在安装activeadmin
之后,我得到了一个admin_users.rb
模型。
我还有一个users model
,没有Devise
,还有admin_user
后端登录页面,与user
前端页面不同。
undefined local variable or method `private' for #<ActiveAdmin::ResourceDSL:0x00007f8a5ff09830>
Did you mean? print
# app/admin/admin_users.rb
ActiveAdmin.register AdminUser do
menu priority: 2, label: proc{"<i class='fa fa-user-circle-o fa-fw mr10'></i>".html_safe+I18n.t("active_admin.admin_users") }
permit_params :email,:username,:phone, :password, :password_confirmation
after_create do
@user = User.new(admin_user_params)
@user.save
end
index title: proc{ I18n.t("active_admin.admin_users") } do
selectable_column
id_column
column :username
column :email
column :phone
column :created_at
actions
end
filter :username
filter :email
filter :created_at
form do |f|
f.inputs do
f.input :username
f.input :phone
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end
private
def admin_user_params
params.require(:admin_user).permit(:email,:username,:phone, :password, :password_confirmation)
end
end
1,建立新的admin_user记录时,用户模型也可以创建此用户记录;
2,当我在后端登录admin_user时,也要在前端登录。
非常感谢!