Answer the question
In order to leave comments, you need to log in
[RoR] How to organize iteration in the scope of the where method?
scope :with_size_ids, lambda { |size_ids|
sizes = Catalog::Size.find(size_ids)
sizes.map do |size|
where('product.size >= ? AND product.size <= ? ', size.max_from, size.max_to)
end
}
where('product.size >= ? AND product.size <= ? ', 0, 100).where('product.size >= ? AND product.size <= ? ', 200, 300) # И так далее
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question