Anton
unread,Dec 3, 2009, 11:40:55 AM12/3/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to factory_girl
Hi!
I have a User (has_one :company) and a Company (belongs_to :user).
I have two factories for the users:
Factory.define :employee_without_company, :class => User do |f|
f.company nil
Factory.define :employee, :class => User do |f|
# HERE is the problem
and one for the company:
Factory.define :company do |f|
f.association :user, :factory => :employee_without_company
The problem is: If I call Factory(:employee) the .company is always
nil.
I tried (at HERE):
1) f.association :company
2) f.company {|comp| comp.association :company }
3) f.after_create {|usr| usr.company = Factory(:company, :user =>
usr)}
4) removed the association command from the company factory
5) set the association in the company to the employee_without_company
6) ... some other stuff
but I cant get a user with a valid association to a company.
The results are: stack level too deep or company is nil.
Can anybody help me out?
Thank you very much in advance!
Regards,
Anton