2013-07-16 2 views
1

몽고이드에서 연장 협회 소유주에게가는 방법을 고민 중입니다. ActiveRecords의 proxy_association.owner를 AFAIK하십시오.몽고이드 연예인 연장 프록시 주인

class Something 
    field :some_field 

    has_many :whatevers, extend: ExtraStuff 
end 

module ExtraStuff 
    def recent 
    # I need "some_field" here, but there's no "proxy_association" 
    end 
end 

답변

0

나는 '기본'이 당신이 찾고있는 방법이라고 생각합니다! 그냥 참조

class Something 
    field :some_field 

    has_many :whatevers, do 
     def my_extension_method 
     klass # Something 
     base # #<Something _id="..." > 
     end 
    end 
end 

: https://github.com/mongoid/mongoid/issues/3171