It looks like your trying to save over a collection, which would be a destructive operation - eliminate the array.
f = Foo.first f.bars.create(:thing => true) or b = f.bars.new(:thing => false) b.save If your trying to make multiple records with the same function call, I've not done it - you'd have to check the api, but I don't think new or create accepts an array. I think if you did foo_bar_stuff.each do |b| f.bars.new(:name => b) end f.save all ur bars would be saved as tersly as possible - that's normally dm's thing. -- Sent from my Palm Pixi On Mar 16, 2010 5:58 PM, [email protected] <[email protected]> wrote: Today's Topic Summary Group: http://groups.google.com/group/datamapper/topics has n collection assignment [1 Update] Topic: has n collection assignment morbusg <[email protected]> Mar 15 02:07AM -0700 ^ Hi, require 'rubygems' require 'dm-core' DataMapper.setup(:default, 'sqlite3::memory:') class Foo include DataMapper::Resource property :id, Serial property :name, String has n, :bars end class Bar include DataMapper::Resource property :id, Serial property :name, String belongs_to :foo end DataMapper.auto_migrate! @foo = Foo.new(:name => 'baz') @foo.bars = [Bar.new(:name => 'lala'), {:name => 'diudiu'}] puts @foo.save @foo = Foo.first @foo.bars = [Bar.new(:name => 'test'), {:name => '123'}] puts @foo.save => true false How is this meant to work? -- You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en. -- You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en.
