title: FactoryGirl association with different name
body: <p>I have the following associations</p>
  
  <pre><code>class Training &lt; ApplicationRecord
    has_many :attendances
    has_many :attendees, through: :attendances
  end
  
  class Attendance &lt; ApplicationRecord
    belongs_to :training
    belongs_to :attendee, class_name: 'Employee'
  </code></pre>
  
  <p>The Attendance table has <code>attendee_id</code> and <code>training_id</code>.</p>
  
  <p>Now, How can I create a valid <code>Attendance</code> with FactoryGirl?</p>
  
  <p>Currently, I have the following code</p>
  
  <pre><code>FactoryGirl.define do
    factory :attendance do
      training
      attendee
    end
  end
  
  FactoryGirl.define do
    factory :employee, aliases: [:attendee] do
      sequence(:full_name) { |n| "John Doe#{n}" }
      department
    end
  end
  </code></pre>
  
  <p>But I get</p>
  
  <pre><code>  NoMethodError:
         undefined method `employee=' for #&lt;Attendance:0x007f83b163b8e8&gt;
  </code></pre>
  
  <p>I have also tried </p>
  
  <pre><code>FactoryGirl.define do
    factory :attendance do
      training
      association :attendee, factory: :employee
    end
  end
  </code></pre>
  
  <p>With the same outcome.</p>
  
  <p>Thanks for your help (or being polite is not allowed on SO???).</p>