Skip to content

Instantly share code, notes, and snippets.

@agile
Created February 2, 2009 22:51
Show Gist options
  • Save agile/57150 to your computer and use it in GitHub Desktop.
Save agile/57150 to your computer and use it in GitHub Desktop.
class Foo
has_many :bars
has_many :bazs
end
class Bar
belongs_to :foo
has_many :bazs, :through => :foo
end
class Baz
belongs_to :foo
end
@foo = Foo.find(1)
@bar = @foo.bars.build(:foo => @foo)
# Why even passing the @foo instance explicitly in,
# I my through association for bazs doesn't get populated?
@foo.bazs => [1, 2, 3]
@bar.bazs => []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment