Hi,
given following models:
class Company < ActiveRecord::Base
end
class User < ActiveRecord::Base
end
class Seller < Company
has_many :seller_users, :foreign_key => "company_id"
end
class SellerUser < User
belongs_to :seller, :class_name => "Company"
end
class Trader < Company
has_many :trader_users, :foreign_key => "company_id"
end
class TraderUser < User
belongs_to :trader, :class_name => "Company"
end
how can I create SellerUser factory?
My attempt:
FactoryGirl.define do
factory :seller, class: Seller do
name 'My seller'
end
end
FactoryGirl.define do
factory :seller_user, class: SellerUser do #|h|
email '
selle...@email.pl'
association :seller, factory: :seller
end
end
I get folowing exception:
ActiveModel::MissingAttributeError: can't write unknown attribute
`seller_id'
My seller_user doesn't have seller_id attribute, it has company_id
attribute.
Any way to override attribute name?
Hope it makes sense.
Thanks,
Marek