title: A copy of xxx has been removed from the module tree but is still active
body: <p>I'm pretty sure the error has nothing to do with the actual content of the <code>TenantIdLoader</code> module. Instead, it has something to do with <code>ActiveSupport</code> Dependencies.</p>
  <p>I can't seem to get past this error. From what I've read, it's because either <code>ActiveRecord::Base</code> is getting reloaded or <code>Company::TenantIdLoader</code> is getting reloaded, and it's somehow not communicating that. Help, please! I'd really like to be able to get upgraded to Rails 4.2.</p>
  <h1>EDIT</h1>
  <p>I've now learned that it's because I'm referencing <code>Tenant</code> which is getting reloaded automatically. I need to be able to actually reference the class though, so does anyone know how to get around this?</p>
  <p>config/application.rb</p>
  <pre><code>config.autoload_paths += %W( #{config.root}/lib/company )
  </code></pre>
  <p>config/initializers/company.rb</p>
  <pre><code>ActionMailer::Base.send(:include, Company::TenantIdLoader)
  </code></pre>
  <p>lib/company/tenant_id_loader.rb</p>
  <pre><code>module Company
    module TenantIdLoader
  
      extend ActiveSupport::Concern
  
      included do
        cattr_accessor :tenant_dependency
        self.tenant_dependency = {}
    
        after_initialize do
          self.tenant_id = Tenant.active.id if self.class.tenant_dependent? and self.new_record? and Tenant.active.present? and !Tenant.active.zero?
        end
      end
  
      # class methods to be mixed in
      module ClassMethods
    
        # returns true if this model's table has a tenant_id
        def tenant_dependent?
          self.tenant_dependency[self.table_name] ||= self.column_names.include?('tenant_id')
        end
    
      end
  
    end
  end
  </code></pre>