ruby on rails - Can I use the syntax parent.Childs.create multiple times, when declaring a parent and two child records? -


customer=customer.new #create new customer object customer.id =1000+i #id needs set first because otherwise automatically set customer.update_attributes(     :fname=>'mike',     :lname=>'hancock',     :year=>1998,     :model=>'buick',     :engine=>'4 liter',     :vinnum=>'h920129801298',     :signupdate=>"#{date.today}",     :password=>'fguygfyed', )     contact=contact.create(         :customer_id=>customer.id, #set foreign primary key         :contactmethod=>4567894561,         :contacttype=>"sms",         :dateadded=>"#{date.today}",     )     customer.contacts.create(         :contactmethod=> 4657894564,         :contacttype=> 'email',         :dateadded=> "#{date.today}",     )     i+=1 end 

this code works. however, if instead of

contact=contact.create( :customer_id=>customer.id, #set foreign primary key

i wrote customer.contacts.create wrote @ end code fails. why can have 1 instance of customer.contacts.create , other have explicitly declare customer.id?

method names declared lower-case. doesn't seem valid.

what intend is:

customer.contacts.create(...) 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -