title: Rails: How to create a has_many through association with an alias/class_name
body: <p>I am trying to transform my HABTM to has_many through relations. Sometimes I have to connect the same models in different ways. For example to specify different roles for authors.</p>
  
  <p>With a HABTM I would do this through the declaration of a class_name option. Just like:-</p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
    has_and_belongs_to_many :curators, :class_name =&gt; :author, :through =&gt; :projects_curators
  end
  
  class ProjectsCurator &lt; ActiveRecord::Base  
    attr_accessible :project_id, :author_id
    belongs_to :project
    belongs_to :author
  end
  
  class Author &lt; ActiveRecord::Base
   has_and_belongs_to_many :projects, :through =&gt; :projects_curators
  end
  </code></pre>
  
  <p>But when I transform everything into a has_many through:  </p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
    has_many :project_curators
    has_many :curators, :class_name =&gt; :author, :through =&gt; :project_curators
  end
  
  class ProjectCurator &lt; ActiveRecord::Base  
    attr_accessible :project_id, :author_id
    belongs_to :project
    belongs_to :author
  end
  
  class Author &lt; ActiveRecord::Base
    has_many :project_curators
    has_many :projects, :through =&gt; :project_curators
  end
  </code></pre>
  
  <p>I get: <code>Could not find the source association(s) :curator or :curators in model ProjectCurator. Try 'has_many :curators, :through =&gt; :project_curators, :source =&gt; &lt;name&gt;'. Is it one of :author or :project?</code></p>
  
  <p>When I add <code>:source</code></p>
  
  <pre><code>has_many :curators, :class_name =&gt; :author, :through =&gt; :project_curators, :source =&gt; :author
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>uninitialized constant Project::author
  </code></pre>
  
  <p>How can I get this working? Thank you very much in advance!</p>