我有一个带有 Globalize3 名称翻译的好模型,所以:good.name(:en) return en good name。good.name(:ru) 返回 rus 好名字。我需要按字母顺序对 Good 进行排序,取决于当前语言,所以(我想是的)我需要做
index ... as :en_name
index ... as :ru_name
然后搜索 (order : "en_name asc" ) 例如。
我有:
good.translations
=> [#<Good::Translation id: 5, good_id: 3, locale: "**ru**", name: "**Аурелия** ", description: "\"Lorem ipsum dolor sit amet, consectetur adipisicin...", created_at: "2012-12-24 13:43:37", updated_at: "2012-12-24 13:43:37">,
#<Good::Translation id: 6, good_id: 3, locale: **"en"**, name: "**Aurelia**", description: "\"Lorem ipsum dolor sit amet, consectetur adipisicin...", created_at: "2012-12-24 13:43:37", updated_at: "2012-12-24 13:43:37">]
并且需要对每个商品做索引 en_name 和 ru_name。像这样的东西:
indexes "translations(:name) where locale='en'", :as => :en_name, sortable: :insensitive
但它不起作用。怎么做?