Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3958

Ruby 2.2 error with mongoize_time

    • Type: Icon: Task Task
    • Resolution: Done
    • 5.0.0
    • Affects Version/s: None
    • Component/s: None

      Hi,
      I have a Rails 4.1.0 app where I just changed to use Ruby 2.2 and gives the error below.
      Mongoid version is 4.0.1

      NoMethodError - undefined method `year' for nil:NilClass:
        activesupport (4.1.0) lib/active_support/values/time_zone.rb:290:in `parse'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/extensions/string.rb:48:in `__mongoize_time__'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/extensions/date.rb:64:in `mongoize'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/fields/standard.rb:10:in `mongoize'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/attributes.rb:291:in `typed_value_for'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/attributes.rb:174:in `block in write_attribute'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/threaded/lifecycle.rb:26:in `_assigning'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/attributes.rb:170:in `write_attribute'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/fields.rb:457:in `block (2 levels) in create_field_setter'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/attributes/processing.rb:97:in `process_attribute'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/attributes/processing.rb:25:in `block in process_attributes'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/attributes/processing.rb:23:in `process_attributes'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/attributes.rb:205:in `block in assign_attributes'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/threaded/lifecycle.rb:26:in `_assigning'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/attributes.rb:204:in `assign_attributes'
         () Users/josegranado/.rvm/gems/ruby-2.2.0@rails4.1.0/bundler/gems/mongoid-35aea60b285a/lib/mongoid/persistable/updatable.rb:51:in `update'
        app/controllers/shipments_controller.rb:110:in `parcels'
        actionpack (4.1.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
        actionpack (4.1.0) lib/abstract_controller/base.rb:189:in `process_action'
        actionpack (4.1.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
      ...
      

      The model involved looks like this:

      class Shipment
        include Mongoid::Document
        include Mongoid::Timestamps
         
        field :pickdate, type: Date
        ...
        ...
      end 
      

      It was previously working fine with Ruby 2.1.5 and I can come back to that version easily, but wanted check if there's any hints how to solve it. Apparently caused by Ruby 2.2 but the resolution might be on mongoid.

            Assignee:
            Unassigned Unassigned
            Reporter:
            josegrad josegrad
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: