【发布时间】:2013-12-06 18:34:57
【问题描述】:
将 Rails 4 与 ActiveAdmin 5 以及 CanCan 和 Rolify 结合使用,我希望能够(通过复选框列表或其他方式)在通过 Active Admin 界面编辑或创建新用户时选择将应用于每个用户的角色。
这篇帖子How to use ActiveAdmin on models using has_many through association? 显示了构建表单的方法。虽然我收到错误:
undefined method `new_record?' for nil:NilClass
在执行form do |f| 时仅访问.has_many 属性时似乎会发生这种情况
f.has_many :roles do |app_f|
#app_f.inputs "Roles" do
#if !app_f.object.nil?
# show the destroy checkbox only if it is an existing appointment
# else, there's already dynamic JS to add / remove new appointments
#app_f.input :_destroy, :as => :boolean, :label => "Destroy?"
#row app_f.role.name
#end
# app_f.input :roles # it should automatically generate a drop-down select to choose from your existing patients
#end
end
【问题讨论】:
标签: ruby-on-rails-4 activeadmin cancan rolify