Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person < ActiveRecord::Base
- has_many :parent_children
- has_many :children, :through => :parent_children
- has_many :parents, :through => :parent_children
- end
- class ParentChild < ActiveRecord::Base
- belongs_to :parent, :class_name => "Person"
- belongs_to :child, :class_name => "Person"
- scope :mother, lambda {
- joins(:parent).where("parent.gender = 'F'")
- }
- scope :father, lambda {
- joins(:parent).where("parent.gender ='M'")
- }
- end
Add Comment
Please, Sign In to add comment