Rails 4.2.6 FactoryGirl with polymorphic association
<p>I have a problem setting up factories for my polymorphic associations with FactoryGirl. My model and factory setup looks like this:</p>

<pre><code>class Address &lt; ActiveRecord::Base
  belongs_to :addressable, polymorphic: true
end

class Customer &lt; ActiveRecord::Base
  has_one :address, as: :addressable
end 

factory :address do
      village Faker::Address.city
      upazilla Faker::Address.street_name
      ward Faker::Address.street_address
      district Faker::Address.state
      association :addressable
end


factory :customer ,class: Customer do 
      recharge_token 10 
      date_of_birth Faker::Date.backward(100)
      manager
      after(:create) do |customer| 
         customer.address = create(:address, addressable: customer)
        #create( :address, addressable: customer)
      end     
end
</code></pre>

<p>The test suite breaks with the following error message </p>

<pre><code> vendor/cache/ruby/2.2.0/gems/factory_girl-4.7.0/lib/factory_girl/linter.rb:12:in `lint!': The following factories are invalid: (FactoryGirl::InvalidFactoryError)
 * address - Factory not registered: addressable (ArgumentError)
</code></pre>

<p><a href="https://stackoverflow.com/questions/21270041/factory-girl-with-polymorphic-association-for-has-many-and-has-one">This</a> is exactly my problem but unfortunately his solution is not working for me. Thanks you all for your time!</p>