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
Post a Comment