0
我有两个模型,一对多关联,Account
,它有多个User
。如何在rails中添加一个表单,创建2个具有1对多依赖关系的模型?
我想为帐户注册表单,该帐户还会为该帐户创建第一个用户。
我Account
型号:
class Account < ActiveRecord::Base
has_many :users, dependent: :destroy
validates :name, presence: true, length: { maximum: 100 }
end
我User
型号:
class User < ActiveRecord::Base
belongs_to :account
validates :account_id, presence: true
如何创建,创建一个帐户,并在同一时间的用户和需要去的形式我的accounts_controller
和我的users_controller
?