ruby on rails - Efficient way to query on children based on a parent filter mongo mapper -


here 2 models have:

 class parent   many :children   key name  end   class children   belongs_to :parent   key price   key description  end 

i want find children have parent particular name let's test.

i with

children.all.select{|a| a.parent.name == "test"} 

but define scope in children class possible using clause?

i tried with

scope :parent_name, where("parent.name" => "test") 

but not work.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -