I have two models:
User
has_one :email
belongs_to :user
I put the email_id foreign key (NOT NULL) inside users table. Now I'm trying to save it in the following way:
@email = Email.new(params[:email])
@email.user = User.new(params[:user])
@email.save
This raises a db exception, because the foreign key constraint is not met (NULL is inserted into email_id). How can I elegantly solve this or is my data modeling wrong?