0
 Lesson.joins(:custom_attributes).where("custom_attributes.attribute_name_id = 103 AND cast(custom_attributes.value as float) BETWEEN 0 AND 61").where("custom_attributes.attribute_name_id = 103 AND cast(custom_attributes.value as float) BETWEEN 0 AND 61").where("attribute_name_id = 112 AND custom_attributes.value LIKE '%55%'")

Above is an example of what I am trying to achieve. When I try:

Lesson.joins(:custom_attributes).where("custom_attributes.attribute_name_id = 103 AND cast(custom_attributes.value as float) BETWEEN 0 AND 61").where("custom_attributes.attribute_name_id = 103 AND cast(custom_attributes.value as float) BETWEEN 0 AND 61")

It returns the right record. But when I chain the query with another, it doesn't get any records even though there are records that satisfy both conditions. I think it has something to do with selecting the custom_attributes.attribute_name_id?

4

0 回答 0