title: How to do has_many with a model that is in a namespace
body: <p>Rails 3 gave us these nice generators that place models and controllers into namespaces, whoo!  But now I'm unable to associate them with other models.</p>
  
  <p>I'm trying to achieve a has_many through association with namespaced models.  I've been searching around the internet for a few days and I haven't come up with any examples.</p>
  
  <p>/app/models/templates/practice.rb</p>
  
  <pre><code>class Templates::Practice &lt; ActiveRecord::Base
    has_many :practice_sequences, :order =&gt; "position", :dependent =&gt; :destroy, :class =&gt; 'Templates::PracticeSequence'
    has_many :seasons, :through =&gt; :practice_sequences, :order =&gt; "position", :class =&gt; 'Templates::Season'
  end
  </code></pre>
  
  <p>/app/models/templates/season.rb</p>
  
  <pre><code>class Templates::Season &lt; ActiveRecord::Base
    has_many :practice_sequences, :order =&gt; "position", :class =&gt; 'Templates::PracticeSequence'
    has_many :practices, :through =&gt; :practice_sequences, :order =&gt; "position", :class =&gt; 'Templates::Practice'
  end
  </code></pre>
  
  <p>/app/models/templates/practice_season.rb</p>
  
  <pre><code>class Templates::PracticeSequence &lt; ActiveRecord::Base
    belongs_to :practice, :class =&gt; 'Templates::Practice'  
    belongs_to :season, :class =&gt; 'Templates::Season'
  end
  </code></pre>
  
  <p>And here is the error </p>
  
  <pre><code>/Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.1/lib/active_support/core_ext/hash/keys.rb:43:in `assert_valid_keys': Unknown key(s): class (ArgumentError)
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.1/lib/active_record/associations.rb:1739:in `create_has_many_reflection'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.1/lib/active_record/associations.rb:983:in `has_many'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activerecord-3.0.1/lib/active_record/autosave_association.rb:137:in `has_many'
   from /Users/jspooner/Documents/SpoonerMedia/FooBars/coach_app/todo/app/models/templates/practice.rb:3
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:227:in `load_dependency'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:346:in `require_or_load'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:300:in `depend_on'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:216:in `require_dependency'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/engine.rb:138:in `eager_load!'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/engine.rb:137:in `each'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/engine.rb:137:in `eager_load!'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/engine.rb:135:in `each'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/engine.rb:135:in `eager_load!'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/application.rb:108:in `eager_load!'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/application/finisher.rb:41
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `instance_exec'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `run'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/initializable.rb:50:in `run_initializers'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `each'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `run_initializers'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/application.rb:134:in `initialize!'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/application.rb:77:in `send'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/railties-3.0.1/lib/rails/application.rb:77:in `method_missing'
   from /Users/jspooner/Documents/SpoonerMedia/FooBars/coach_app/todo/spec/../config/environment.rb:5
   from /Users/jspooner/Documents/SpoonerMedia/FooBars/coach_app/todo/spec/spec_helper.rb:12:in `require'
   from /Users/jspooner/Documents/SpoonerMedia/FooBars/coach_app/todo/spec/spec_helper.rb:12
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/spork-0.9.0.rc2/lib/spork.rb:23:in `prefork'
   from /Users/jspooner/Documents/SpoonerMedia/FooBars/coach_app/todo/spec/spec_helper.rb:7
   from /Users/jspooner/Documents/SpoonerMedia/FooBars/coach_app/todo/spec/helpers/templates/practice_templates_helper_spec.rb:1:in `require'
   from /Users/jspooner/Documents/SpoonerMedia/FooBars/coach_app/todo/spec/helpers/templates/practice_templates_helper_spec.rb:1
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/lib/rspec/core/configuration.rb:327:in `load'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/lib/rspec/core/configuration.rb:327:in `load_spec_files'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/lib/rspec/core/configuration.rb:327:in `map'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/lib/rspec/core/configuration.rb:327:in `load_spec_files'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/lib/rspec/core/command_line.rb:18:in `run'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/lib/rspec/core/runner.rb:55:in `run_in_process'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/lib/rspec/core/runner.rb:46:in `run'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/lib/rspec/core/runner.rb:10:in `autorun'
   from /Users/jspooner/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.2.1/bin/rspec:4
  </code></pre>