1
0
Fork 0
forked from OpenNeo/impress

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.
This commit is contained in:
Matchu 2015-09-24 19:51:45 -07:00
parent 973bbbcb0a
commit c8b9833dee

View file

@ -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)) }