2012-05-17 2 views

답변

1

"역순으로"연결하면됩니다.

class Zoo 
    #... 
    def self.with_carnivores 
    # Assuming `Animal belongs_to :zoo` 
    Animal.carnivores.zoo 
    end 
    #... 
end 

class Habitat 
    #... 
    def self.with_carnivores 
    # Assuming `Animal has_many :habitats` 
    Animal.carnivores.habitats 
    end 
    #... 
end