i'm having the same problem... have you solved it?
Thanks
On Nov 21, 12:41 pm, John Nunemaker <
nunema...@gmail.com> wrote:
> I think the most simple thing would be to make sure that when we are
> to_json'ing any key that is an object id, we should just call to_s
> first. That would probably be the most simple. I'm doing this for _id
> already.
>
> On Sat, Nov 21, 2009 at 9:11 AM, Felipe Coury <
felipe.co...@gmail.com> wrote:
> > John,
> > I am nowhere near confident that this is the fix, but changing the ObjectId
> > class in types.rb to treat the hash that mongo gem's ObjectID spit when
> > converting to JSON spits made it work, look:
> > class ObjectId
> > def self.to_mongo(value)
> > if value.nil?
> > nil
> > elsif value.is_a?(Mongo::ObjectID)
> > value
> > elsif value.is_a?(Hash)
> > Mongo::ObjectID.new(value["data"])
> > else
> > Mongo::ObjectID.from_string(value.to_s)
> > end
> > end
>
> > def self.from_mongo(value)
> > value
> > end
> > end
> > What are your thoughts on this?
> > Thanks,
> > -- Felipe.
>
> > On Sat, Nov 21, 2009 at 11:41 AM, Felipe Coury <
felipe.co...@gmail.com>
> > wrote:
>
> >> I have also changed test_serializations.rb to include the problem:
> >>
http://gist.github.com/240127
> >> It's dirty (declaring classes inside the test) but it reproduces the
> >> problem.
> >> Hope this helps, I'll continue investigating as well...
> >> Thanks!
> >> -- Felipe.
>
> >> On Sat, Nov 21, 2009 at 11:15 AM, Felipe Coury <
felipe.co...@gmail.com>