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

Private method 'fields' called for #<ModelClass> error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Works as Designed
    • Affects Version/s: 7.0.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Rails 5.2.0, Ruby 2.4.3p205, Ubuntu 16.04

      Description

      This error happens only in testing environment and only in Rails 5.2.0. When reverting to Rails 5.1.6 error doesn't appear. So far I also didn't encounter any errors in my development and staging environment.

      Error backtrace:
      NoMethodError: private method `fields' called for #<DcPolicyRole:0x00000000033410e0>
      Did you mean? fields=
      fields?
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/validatable/localizable.rb:19:in `validate_each'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activemodel-5.2.0/lib/active_model/validator.rb:152:in `block in validate'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activemodel-5.2.0/lib/active_model/validator.rb:149:in `each'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activemodel-5.2.0/lib/active_model/validator.rb:149:in `validate'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:426:in `block in make_lambda'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:605:in `catch'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:605:in `block in default_terminator'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:199:in `block in halting'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:513:in `block in invoke_before'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:513:in `each'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:513:in `invoke_before'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:131:in `run_callbacks'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/interceptable.rb:132:in `run_callbacks'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:816:in `_run_validate_callbacks'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activemodel-5.2.0/lib/active_model/validations.rb:409:in `run_validations!'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activemodel-5.2.0/lib/active_model/validations/callbacks.rb:118:in `block in run_validations!'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:98:in `run_callbacks'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/interceptable.rb:132:in `run_callbacks'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:816:in `_run_validation_callbacks'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activemodel-5.2.0/lib/active_model/validations/callbacks.rb:118:in `run_validations!'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activemodel-5.2.0/lib/active_model/validations.rb:339:in `valid?'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/validatable.rb:97:in `valid?'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/activemodel-5.2.0/lib/active_model/validations.rb:376:in `invalid?'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/persistable/creatable.rb:117:in `prepare_insert'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/persistable/creatable.rb:23:in `insert'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/persistable/creatable.rb:180:in `block in create!'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/threaded/lifecycle.rb:161:in `_creating'
      /home/rails/Testiranje/vendor/ruby/2.4.0/gems/mongoid-6.4.0/lib/mongoid/persistable/creatable.rb:175:in `create!'
      /home/rails/drg_cms/test/fixtures/drg_cms_test_data.rb:6:in `drg_cms_test_data_fill'

      Line 6 of drg_cms_test_data.rb:
      sa_role = DcPolicyRole.create!(name: 'superadmin', system_name: 'superadmin')

      by
      TheR

        Attachments

          Activity

            People

            Assignee:
            sam.rossi Samuel Rossi (Inactive)
            Reporter:
            ther Damjan Rems
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: