I am creating contacts & users in the DB in seed.rb
. Using the code below, the contact is saved but the child user is not. What am I missing? I've tried with and without the if
statement, and the user is never saved.
Models
class Contact < BaseModel
#...
has_one :user
end
class User < BaseModel
#...
belongs_to :contact
end
Seed
contact = Contact.where({
:first_name => "Some",
:last_name => "Person",
:email => "some.person@domain.com",
:zip => "12345"}).first_or_initialize
contact.build_user if contact.user == nil
contact.save!