我正在使用 rolify+activeadmin gems。我有 2 个资源:员工和用户(默认设计表)。员工是一个映射只读表的模型,所以我不能在员工表中写入。我正在尝试与活动管理员一起使用 has_one 和 belongs_to 关联为用户添加角色:
class User < ActiveRecord::Base
rolify
belongs_to :staff
end
class Staff < ActiveRecord::Base
has_one :user
end
在 app/admin/staff.rb 类中我有这个:
form do |f|
f.inputs "Add role" do |staff|
f.input :roles, :as => :select, :collection => Role.global
end
f.actions
end
So i want to add a role for a user using Staff admin resource.
when i click on submit form button i have this error:
NoMethodError in Admin/staffs#edit
Showing app/views/active_admin/resource/edit.html.arb where line #1 raised:
undefined method `roles' for #<Staff:0x00000005c6af70>
Extracted source (around line #1):
1: insert_tag renderer_for(:edit)