我的应用程序要求Courses
with Projects
with我需要确保每次不会出现超过一次,我认为我可以通过 Rails 验证来做到这一点,但我所拥有的似乎并不想工作。谁能帮我解决这个问题?Groups
Users.
users
project
以下给了我:
NoMethodError in Admin::GroupsController#create
undefined method `text?' 对于零:NilClass
class Group < ActiveRecord::Base
attr_accessible :name, :project_id
#has_and_belongs_to_many fields
attr_accessible :user_ids
has_and_belongs_to_many :users
belongs_to :project, :inverse_of => :groups
validates :name, :project_id, :presence => true
validates :user_ids, :uniqueness => { :scope => :project_id,
:message => "Users can only be in one group per project." }
end
ActiveAdmin 组对象:
ActiveAdmin.register Group do
form do |f|
f.inputs do
f.input :name
f.input :users, :as => :check_boxes
f.input :project
end
f.buttons
end
end