From 578c59ce04f1d36006bd6770226845771b7ef3f9 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 29 Jul 2023 13:11:53 -0700 Subject: [PATCH] Oops, fix ambiguous zones_restrict column When combining occupies and restricts filters, this wouldn't be sure whether to apply to the items or the swf assets. --- app/models/item.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/item.rb b/app/models/item.rb index dbca9405..a383e02d 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -96,12 +96,12 @@ class Item < ActiveRecord::Base } scope :restricts, ->(zone_label, locale = I18n.locale) { zone_ids = Zone.matching_label(zone_label, locale).map(&:id) - condition = zone_ids.map { '(SUBSTR(zones_restrict, ?, 1) = "1")' }.join(' OR ') + condition = zone_ids.map { '(SUBSTR(items.zones_restrict, ?, 1) = "1")' }.join(' OR ') where(condition, *zone_ids) } scope :not_restricts, ->(zone_label, locale = I18n.locale) { zone_ids = Zone.matching_label(zone_label, locale).map(&:id) - condition = zone_ids.map { '(SUBSTR(zones_restrict, ?, 1) = "1")' }.join(' OR ') + condition = zone_ids.map { '(SUBSTR(items.zones_restrict, ?, 1) = "1")' }.join(' OR ') where("NOT (#{condition})", *zone_ids) } scope :fits, ->(body_id) {