Displaying 1 result from an estimated 1 matches for "test_habtm".
2006 Aug 09
3
HABTM and getting to arrays from either direction
I didn''t find exactly an answer on this one, so I''d like to get a
clarification from folks who live & breathe HABTM.
class foo
has_and_belongs_to_many :bars
end
class bar
has_and_belongs_to_many :foos
end
(and yes, I have a bars_foos table in my db)
def test_habtm
bar = Bar.new
foo = Foo.new
foo.bars<<bar
assert !foo.bars.empty?
assert !bar.foos.empty?
end
My first assert passes just fine. But the 2nd fails. Am I wrong on the
concepts of HABTM? Shouldn''t the << operator add to the join table and
therefore the next find fr...