activerecord - rails how to save a model with has_many through association -
i having models
// contains details of parties (users) class party < activerecord::base has_many :party_races has_many :races, :through=>:party_races end // contains party_id , race_id mappings class partyrace < activerecord::base belongs_to :party belongs_to :race end // contains list of races asian,american,etc.. class race < activerecord::base has_many :party_races has_many :parties, :through => :party_races end
now, lets i'm creating instance of party party_instance = party.new
how supposed add multiple races party_instance
, save database ?
you use nested attributes make 1 form allows children. there many examples on site. read on following first:
Comments
Post a Comment