Let's say I have a record in my database that has:
name: "World\u0092s Greatest Jet Fighter Pilot"
OK I need to get in there and clean out the \u0092
(there were a ton of these in the db). I can query like this:
# encoding: UTF-8
...
def self.by_partial name
return Movie.find(:all, :conditions => {:name => /^.*#{name}.*/i})
end
# console:
>> sel = Movie.by_partial(/Greatest/) and sel.size
=> 1
and get back the correct number of records. But when I throw in the unicode, it fails:
>> sel = Movie.by_partial(/\u0092/) and sel.size
=> 0
>> sel = Movie.by_partial(/\\u0092/) and sel.size
=> 0
>> sel = Movie.by_partial('\u0092') and sel.size
=> 0
>> sel = Movie.by_partial('\\u0092') and sel.size
=> 0
What do I need to do to be able to query for records that contain unicode characters? Is this a setting in the rails console? I managed to solve this by iterating the records and checking like so if mov.name =~ /\u0092/ ...
but I can't figure out how to pass a unicode string into my mongoid selector. Iterating the records seemed way too brute force. Luckily I don't need to do this very often.