title: How can I load HABTM-with-foreign-key relationships in my fixtures?
body: <p>I have the following two models: School and User, and a HABTM relationship between them, with a join table. </p>
  
  <p>In this join table, the foreign key refering to the User table is not called <code>user_id</code> but <code>student_id</code>.</p>
  
  <pre><code>class School &lt; ActiveRecord::Base
   has_and_belongs_to_many :students, :class_name =&gt; "User", :join_table =&gt; "schools_students", :foreign_key =&gt; "student_id"
  end
  
  class User &lt; ActiveRecord::Base
   has_and_belongs_to_many :studying_schools, :class_name =&gt; "School", :join_table =&gt; "schools_students", :foreign_key =&gt; "school_id"
  end
  </code></pre>
  
  <p>I would like to create in my Users and Schools fixtures a school and a user, but the foreign_key defined in User seems to be a problem.</p>
  
  <p><code>fixtures/users.yml</code> :</p>
  
  <pre><code>user1:
    name: Student
    studying_schools: school1
  </code></pre>
  
  <p><code>fixtures/schools.yml</code> :</p>
  
  <pre><code>school1:
    name: School 1
    active: true
    students: user1
  </code></pre>
  
  <p>Loading the fixtures above returns an ActiveRecord exception :
  <code>ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'user_id' in 'field list': INSERT INTO schools_students (student_id, user_id) VALUES (6562055, 14302562)</code></p>
  
  <p>What am I doing wrong ?</p>