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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -