formstatic 属于并处于活动状态的管理员

formstatic belongs to and active admin

当我尝试添加新用户

时,我遇到了活动管理员的问题

我有角色 table 管理员和讲师 但是如何显示它们 这是我的 user.rb 管理目录中的文件

ActiveAdmin.register User do
  form do |f|
    f.inputs "new user" do
      f.inputs :f_name
      f.inputs :l_name
      f.inputs :age
      f.inputs :job_title
      f.inputs :slug
      f.inputs :birthdate
      f.inputs :country
      f.inputs :role
      f.semantic_fields_for :images do |fi|
        fi.input :photo, :as => :file
      end
    end
    f.button :submit 
  end
end

谁能帮帮我?

您可以执行以下操作:

 f.inputs :role, :as => :select, :collection => # write here the code produce `id`s that will be saved in database, and a string that will actually be shown on the web page. 

感谢当我把这个功能放在我的角色模型中时它起作用了 定义 to_s 钥匙 结尾 并把这个 f.inputs :role, :collection => Role.all.map{ |角色| [role.key, role.id]} 在管理目录 user.rb 中