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)