0

更像是压倒一切的顺序

Entity.associations.order("field ASC").reorder("other_field DESC") 
# => result: GET ... order by other_filed DESC

是否可以覆盖范围选项?

Entity.associations.where("field = 1").where("field = 2")
# => GET ... where "field" = 1 and "field" = 2

# Desirable:
Entity.associations.where("field = 1").rescope(where("field = 2"))
# => GET ... where "field" = 2

PS
导轨 3

PSS 接受的答案对 Rails4 有效

4

1 回答 1

2

您可以使用unscope方法完全删除您的 where 条件:

Entity.asscocations.where(field: 1).unscope(:where).where(field: 2)

或者只是从您的 where 条件中删除特定字段:

Entity.asscocations.where(field: 1).unscope(where: :field).where(field: 2)
于 2013-11-05T15:07:24.927 回答