不在 activerecord rails 的地方

not in rewhere active record rails

如何在 active_record 中将 'not' 与 'rewhere' 语句一起使用?

错误示例(无效):

Field.where(name: 'Bukk').rewhere.not(name: 'Tolgy')

您可能需要 unscope 您的姓名条件并再次添加:

Field.where(name: 'Bukk').unscope(where: :name).where.not(name: 'Tolgy')

rewhere 使用 unscope 来完成它的工作。