I am currently using mongo_mapper and for some reason I am getting a bad comparison of timestamps when ever a database record is read. The actual error message I receive is as follows:
Exception NoMethodError' at /Users/ghickey/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.8/lib/active_support/core_ext/date_time/calculations.rb:142 - undefined methodcoerce' for nil:NilClass
NoMethodError' at /Users/ghickey/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.8/lib/active_support/core_ext/date_time/calculations.rb:142 - undefined method
In examining the calculations.rb file, the final method is
I have been finding that other is not nil, but instead blank. Inserting a test for a blank value and returning a -1 does not throw an exception.
@hickey could not simulate your problem here. Please describe it better.
@rafaelfranca , @carlosantoniodasilva puts this issues in label '3-2-stable', she is as 'master'. Thanks!
I wonder if this is somehow related to #2797 - @hickey do you use any gems that override <=> on DateTime ?
@hickey what gems you use?
I did some tests with Date, Time and DateTime in an application to use the mongoid, and had no problems.
@hickey Mongo stores dates as times (or strings) and so there is conversion happening in Mongo and/or MongoMapper to produce dates into Rails. It is likely this is happening in a fashion that is bypassing the ActiveSupport extended Date hence the lack of coerce. Can you produce a failing test case for Rails? You could also ask the MongoMapper team for help on this.
@hickey it's been a few months since we've heard from you, and as @JonRowe mentions, it's quite possible this is a Mongo/MongoMapper issue. Unless we can prove somehow that this is actually a bug in Rails, I'm going to give this a close. Thanks.