From c8b9833dee26f70d0001892b69cf6ec3f99bdf2b Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 24 Sep 2015 19:51:45 -0700 Subject: [PATCH] fix the necklace/collar advanced search bug! Ooh, this one was nasty, and only one symptom ever got noticed: 1. Pick "Occupies: Collar" in Advanced Search. You get the text query "occupies:necklace". 2. And, if you try to do "occupies:collar" even in text-based search, you *also* get the results from "occupies:necklace" mixed in with the correct results. The trick is that, in Spanish, zone 24 (necklace) is named "collar", as is zone 27 (collar). Not sure what to do for Spanish, but this issue also leaked into English: we really don't want English to return results for Spanish-named zones. This is a tricky problem, though, because it'd be nice for es users to be able to type "occupies:hat". I think we'll have to do the quick fix for now, though, and just only interpret the query in the current locale. --- app/models/zone.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/zone.rb b/app/models/zone.rb index 56af9ffe..2b280907 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -11,7 +11,9 @@ class Zone < ActiveRecord::Base scope :includes_translations, lambda { includes(:translations) } scope :with_plain_label, lambda { |label| t = Zone::Translation.arel_table - includes(:translations).where(t[:plain_label].eq(Zone.plainify_label(label))) + includes(:translations) + .where(t[:plain_label].eq(Zone.plainify_label(label))) + .where(t[:locale].eq(I18n.locale)) } scope :for_items, lambda { where(arel_table[:type_id].gt(1)) }