0
我有一個很好的模型,具有Globalize3名稱轉換,所以: good.name(:en)返回一個好名字。 good.name(:ru)return rus good name。 我需要排序按字母順序排列好,當前語言的depence,所以(我這麼認爲)我需要思維獅身人面像:索引翻譯屬性
index ... as :en_name
index ... as :ru_name
,然後搜索(命令:「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
但它不工作。怎麼做?