Created
January 26, 2011 15:43
-
-
Save eqdw/796872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## DOES THIS MAKE SENSE / IS VALID | |
class Foo < ActiveRecord::Base | |
has_many :bar | |
has_many :baz, :through => :bar | |
end | |
class Bar < ActiveRecord::Base | |
belongs_to :baz | |
end | |
class Baz < ActiveRecord::Base | |
end | |
##Does this make sense? Each bar only has one baz. Each foo has multiple bars. Therefore, each foo has multiple bazs, even though a bar only has one? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Foo, you'd want plurals:
has_many :bars ;)
has_many :bazes, :through => :bars (choose a name other than baz haha ;p)
In Bar I'd add foo , so it's
belongs_to :baz
belongs_to :foo
Then in Baz you can do:
has_many :bars
has_many :foos, :through => :bars