On Fri, Apr 22, 2011 at 9:26 PM, Erwin <[email protected]> wrote: > I have an array of Hash to be used for creating records in db with > this format : > > geo_areas.first > => {"id"=>1, "areaOrder"=>1, "areaName"=>"Europe", "areaCode"=>"EUR", > "areaEnabled"=>1} > > I'll loop over the geo_areas array to create all records .. but I need > to use the 'id' key as the :id of my records upon creation > > doing : > GeoArea.new(geo_areas.first) doesn't take the "id" in account > => #<GeoArea id: nil, areaOrder: 1, areaName: "Europe", areaCode: > "EUR", areaEnabled: true> > > You might want to look at the Fixtures class.
I don't know where I got this seeding script before but it uses fixtures to create the records. http://pastie.org/1822406 > and > GeoArea.create(geo_areas.first) auto-generate the id , not taking in > account the "id" in the Hash ... > > how should I proceed ? > > tfyi > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

