Created
August 30, 2010 22:06
-
-
Save adamjt/558128 to your computer and use it in GitHub Desktop.
This file contains 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
class Kitchen < ActiveRecord::Base | |
has_many :cups | |
end | |
class Cup < ActiveRecord::Base | |
has_many :liquids | |
belongs_to :kitchen | |
end | |
class Liquid < ActiveRecord::Base | |
belongs_to :cup | |
has_one :kitchen. :through => :cup | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
scope is a good way to go but this should work as well in rails 3. have not tested but should work but maybe not the most efficient thing ever. just cool you can do it.
first load kitchen with your id:
kitchen.cups.liquids.where(:hot => true)