Skip to content

Instantly share code, notes, and snippets.

@juanghurtado
Created September 5, 2011 16:42
Show Gist options
  • Save juanghurtado/1195430 to your computer and use it in GitHub Desktop.
Save juanghurtado/1195430 to your computer and use it in GitHub Desktop.
Rails 3.1 error on tests
Failure/Error: @user_profile = @user.create_user_profile(@attr)
ActiveRecord::RecordNotSaved:
Failed to remove the existing associated user_profile. The record failed to save when after its foreign key was set to nil.
@raid5
Copy link

raid5 commented Sep 7, 2011

Having a similar issue...any solution?

@juanghurtado
Copy link
Author

Adding :dependent => :destroy to the :has_one attribute of the model solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment