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

Inflection failed to pick up class via embeds_many association

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

      I have a class Institution embeds_many :campuses, I also have a inflection initializers to pick up the this singular correctly. Here is the output in the console:

      Loading development environment (Rails 4.1.1)
      irb(main):001:0> Institution.new.campuses
      NameError: uninitialized constant Campus
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/inflector/methods.rb:238:in `const_get'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/inflector/methods.rb:238:in `block in constantize'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/inflector/methods.rb:236:in `each'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/inflector/methods.rb:236:in `inject'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/inflector/methods.rb:236:in `constantize'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/metadata.rb:575:in `klass'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/embedded/many.rb:448:in `scope'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/embedded/many.rb:240:in `block in initialize'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/proxy.rb:42:in `init'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/embedded/many.rb:234:in `initialize'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/accessors.rb:44:in `new'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/accessors.rb:44:in `create_relation'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/accessors.rb:26:in `__build__'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/accessors.rb:104:in `block (2 levels) in get_relation'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/threaded/lifecycle.rb:125:in `_loading'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/accessors.rb:100:in `block in get_relation'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/threaded/lifecycle.rb:84:in `_building'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/accessors.rb:99:in `get_relation'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/bundler/gems/mongoid-9646fa21222c/lib/mongoid/relations/accessors.rb:187:in `block in getter'
      	from (irb):1
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/console.rb:90:in `start'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
      	from /opt/rubies/1.9.3+envato4/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
      	from bin/rails:8:in `require'
      	from bin/rails:8:in `<main>'irb(main):002:0> 
      

      I pushed my app for investigation here: https://github.com/joneslee85/demo

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

              Created:
              Updated:
              Resolved: