title: Rails Engine - NameError: uninitialized constant
body: <p>I'm creating a Rails Engine Classification, in which I have the Class Passion and a Concern Passionable. </p>
  
  <p>I have also another engine Post, where I include the Passionable Concern. This Passionable Concern belongs to the Engine Classification in the /lib folder.</p>
  
  <p>Turns out that, whenever I try to do a new Post passing the passion_ids, I get this error message:</p>
  
  <blockquote>
    <p>NameError (uninitialized constant Feed::Post::Categorization):</p>
    
    <p>"Categorization" is the jointable that I created in Engine
    Classification.</p>
  </blockquote>
  
  <p>The piece of code is posted down below.</p>
  
  <p><em>Engine Classification</em>
      # passion.rb</p>
  
  <pre><code>module Classification
    class Passion &lt; ApplicationRecord
      ...
      has_many :categorizations
      has_many :posts, as: :categorizable, through: :categorizations
      ...
    end
  end
  
  #==========================================//
  # Classification.rb (JoinTable)
  module Classification
    class Categorization &lt; ApplicationRecord
      belongs_to :passion
      belongs_to :categorizable, polymorphic: true
    end
  end
  
  
  #===========================================//
  # classification/lib/passionable.rb
  
  require 'active_support/concern'
  
  module Classification
    module Passionable extend ActiveSupport::Concern
      included do
        has_many :categorizations, as: :categorizable
        has_many :passions, through: :categorizations
      end
    end
  end
  </code></pre>
  
  <p>Engine Post</p>
  
  <pre><code>module Feed
    class Post &lt; ApplicationRecord
      has_many :pictures, class_name: "Feed::Picture"
  
      include ::Classification::Passionable
      ...
    end
  end
  </code></pre>
  
  <p>Json to create post.</p>
  
  <pre><code>{
      "post": {
          "title": "My post title",
          "content": "Lorem ipsum dolor sit amet..",
          "passion_ids":["8bf8559a-857d-4ca5-82e1-f93dd3effc35","d51747b7-0960-460a-b15a-4b593155e2c5"]
      }
  }
  </code></pre>
  
  <p><strong>ERROR MESSAGE:</strong></p>
  
  <pre><code>NameError (uninitialized constant Feed::Post::Categorization):
  
  activerecord (5.0.2) lib/active_record/inheritance.rb:152:in `compute_type'
  activerecord (5.0.2) lib/active_record/reflection.rb:354:in `compute_class'
  activerecord (5.0.2) lib/active_record/reflection.rb:350:in `klass'
  activerecord (5.0.2) lib/active_record/reflection.rb:745:in `source_reflection'
  activerecord (5.0.2) lib/active_record/reflection.rb:925:in `check_validity!'
  activerecord (5.0.2) lib/active_record/associations/association.rb:25:in `initialize'
  activerecord (5.0.2) lib/active_record/associations/has_many_through_association.rb:8:in `initialize'
  activerecord (5.0.2) lib/active_record/associations.rb:240:in `new'
  activerecord (5.0.2) lib/active_record/associations.rb:240:in `association'
  activerecord (5.0.2) lib/active_record/associations/builder/collection_association.rb:66:in `passion_ids='
  activemodel (5.0.2) lib/active_model/attribute_assignment.rb:46:in `public_send'
  activemodel (5.0.2) lib/active_model/attribute_assignment.rb:46:in `_assign_attribute'
  activemodel (5.0.2) lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes'
  activemodel (5.0.2) lib/active_model/attribute_assignment.rb:39:in `each'
  activemodel (5.0.2) lib/active_model/attribute_assignment.rb:39:in `_assign_attributes'
  activerecord (5.0.2) lib/active_record/attribute_assignment.rb:26:in `_assign_attributes'
  activemodel (5.0.2) lib/active_model/attribute_assignment.rb:33:in `assign_attributes'
  activerecord (5.0.2) lib/active_record/core.rb:319:in `initialize'
  activerecord (5.0.2) lib/active_record/inheritance.rb:65:in `new'
  activerecord (5.0.2) lib/active_record/inheritance.rb:65:in `new'
  engines/feed/app/controllers/feed/posts_controller.rb:21:in `create'
  actionpack (5.0.2) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
  actionpack (5.0.2) lib/abstract_controller/base.rb:188:in `process_action'
  actionpack (5.0.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
  actionpack (5.0.2) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (5.0.2) lib/active_support/callbacks.rb:126:in `call'
  activesupport (5.0.2) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
  activesupport (5.0.2) lib/active_support/callbacks.rb:455:in `call'
  activesupport (5.0.2) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
  activesupport (5.0.2) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
  activesupport (5.0.2) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.2) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (5.0.2) lib/action_controller/metal/rescue.rb:20:in `process_action'
  actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (5.0.2) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (5.0.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
  activesupport (5.0.2) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (5.0.2) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
  activerecord (5.0.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (5.0.2) lib/abstract_controller/base.rb:126:in `process'
  actionpack (5.0.2) lib/action_controller/metal.rb:190:in `dispatch'
  actionpack (5.0.2) lib/action_controller/metal.rb:262:in `dispatch'
  actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
  actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:32:in `serve'
  actionpack (5.0.2) lib/action_dispatch/journey/router.rb:39:in `block in serve'
  actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in `each'
  actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in `serve'
  actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:725:in `call'
  railties (5.0.2) lib/rails/engine.rb:522:in `call'
  railties (5.0.2) lib/rails/railtie.rb:193:in `public_send'
  railties (5.0.2) lib/rails/railtie.rb:193:in `method_missing'
  actionpack (5.0.2) lib/action_dispatch/routing/mapper.rb:17:in `block in &lt;class:Constraints&gt;'
  actionpack (5.0.2) lib/action_dispatch/routing/mapper.rb:46:in `serve'
  actionpack (5.0.2) lib/action_dispatch/journey/router.rb:39:in `block in serve'
  actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in `each'
  actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in `serve'
  actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:725:in `call'
  rack (2.0.1) lib/rack/etag.rb:25:in `call'
  rack (2.0.1) lib/rack/conditional_get.rb:38:in `call'
  rack (2.0.1) lib/rack/head.rb:12:in `call'
  activerecord (5.0.2) lib/active_record/migration.rb:553:in `call'
  actionpack (5.0.2) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
  activesupport (5.0.2) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
  activesupport (5.0.2) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
  activesupport (5.0.2) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.2) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
  actionpack (5.0.2) lib/action_dispatch/middleware/executor.rb:12:in `call'
  actionpack (5.0.2) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
  actionpack (5.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
  actionpack (5.0.2) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
  railties (5.0.2) lib/rails/rack/logger.rb:36:in `call_app'
  railties (5.0.2) lib/rails/rack/logger.rb:24:in `block in call'
  activesupport (5.0.2) lib/active_support/tagged_logging.rb:69:in `block in tagged'
  activesupport (5.0.2) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (5.0.2) lib/active_support/tagged_logging.rb:69:in `tagged'
  railties (5.0.2) lib/rails/rack/logger.rb:24:in `call'
  actionpack (5.0.2) lib/action_dispatch/middleware/request_id.rb:24:in `call'
  rack (2.0.1) lib/rack/runtime.rb:22:in `call'
  activesupport (5.0.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  actionpack (5.0.2) lib/action_dispatch/middleware/executor.rb:12:in `call'
  actionpack (5.0.2) lib/action_dispatch/middleware/static.rb:136:in `call'
  rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
  railties (5.0.2) lib/rails/engine.rb:522:in `call'
  puma (3.8.2) lib/puma/configuration.rb:224:in `call'
  puma (3.8.2) lib/puma/server.rb:600:in `handle_request'
  puma (3.8.2) lib/puma/server.rb:435:in `process_client'
  puma (3.8.2) lib/puma/server.rb:299:in `block in run'
  puma (3.8.2) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
  </code></pre>