我有以下型号:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :encryptable
belongs_to :club
end
和
class Club < ActiveRecord::Base
has_many :users
accepts_nested_attributes_for :users
end
鉴于“accepts_nested_attributes_for”必须在“has_many”方面,我该如何构建一个接受嵌套,设计,用户数据的嵌套表单?
答案 0 :(得分:1)
确定。我认为它应该有效:
控制器:
@users = @ club.users.build
表格:
form_for @club
fields_for @users |fr|
@users.each do |usr|
text_field :email
text_field :password
text_field :pass_conf...
other fields
end
end
submit
end