Factory Girl Association
- by David Lyod
I have an association of a Admin - Account in factory girl
I now wish to associate a second user with the same account but am unable to do so.
I build my Admin-Account association like this
u.account { |account| account.association(:account)}
This works fine and creates the Account and Admin association. Im looking for a way to setup a second user who's account also points to the record created in the Admin factory association.
I currently just build the second user as such
@user = Factory.build(:seconduser)
@user.account = Account.first
@user.save!
Which works but seems somewhat hacky .