Factory Girl with polymorphic association for has_many and has_one
I am currently working on a project and I wanted to create tests using factory girl but I'm unable to make it work with polymorphic has_many association. I've tried many different possibilities mentioned in other articles but it still doesn't work. My model looks like this: class Restaurant < ActiveRecord::Base has_one :address, as: :addressable, dependent: :destroy has_many :contacts, as: :contactable, dependent: :destroy accepts_nested_attributes_for :contacts, allow_destroy: true accepts_nested_attributes_for :address, allow_destroy: true validates :name, presence: true #validates :address,