Displaying 1 result from an estimated 1 matches for "items_things".
2006 Aug 08
12
delete_if doesn''t work for has_and_belongs_to_many
...s Item
has_and_belongs_to_many :things
end
class Thing
has_and_belongs_to_many :items
end
i = Item.new
i.things << Thing.new( :value => "Something").save
i.things << Thing.new( :value => "Something Else" ).save
i.save
Fine, now I have two records in the items_things table. Now if I say
t = Thing.find_by_value ''Something''
i.things.delete t
i.save
Then I have only one record in the items_things table. Which is correct.
But, if I had said
i.things.delete_if {|x| x.value = ''Something''}
i.save
then the relevant record is not...