-
Type:
Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
any_of doesn't suffix the field key with the locale if more than one condition is provided.
- Working fine:
Post.any_of title: 'Hello World' # => { :title.en => 'Hello World' }
- Working not so fine:
Post.any_of title: 'Hello World', description: 'Hello World' # => { :title => 'Hello World', :description => 'Hello World' }
I looked around a little, and it seems to be caused by the []= method in the Selector module because it doesn't recognize these kinds of nested keys. I changed
Unable to find source-code formatter for language: handle_and_or_value. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
(values)
to localize keys and now things work great.
def handle_and_or_value(values)
[].tap do |result|
result.push(*values.map do |value|
Hash[value.map{ |key, value| key = "#
.#{::I18n.locale}" if klass.fields[key.to_s].try(:localized?); [key, try_to_typecast(key, value)] }]
end)
end
end
I'm using Mongoid 2.4.3, and I'm loving it! Keep up the good work