使用 Mongoid / MongoDB,我怎样才能找到一个文档,其名称以任何一种可用语言匹配我的 where 查询?
假设我有一个具有本地化字段和许多翻译的模型
class Foo
field :name, localize: true
end
Foo.create(name_translations: {
'fr' => 'Ingénierie logicielle',
'en' => 'Computer Software'
})
该.find_by(name: )
方法似乎只能找到I18n.current
语言(在我的情况下是法语),我如何搜索所有翻译?
我正在尝试几种变体Foo.find_by(name_translations: 'Computer Software)
,但我仍然得到空的结果......