Ruby on Rails Saturday, June 10, 2017

I had a Profile model that everything else belonged to and Profile in turn belonged to user The idea was that a user could have multiple accounts/identifies/personas whatever you wanna call them because people do it anyway with separate accounts At some point I decided I don't really wanna do that so I took out the Profile model Now when I try to create a new Post rails complains that user_id references profiles_id but I can't find where rails is getting the foreign key from Is it a temporary file I have to delete? Thanks in advance

ActiveRecord::InvalidForeignKey (Mysql2::Error: Cannot add or update a child row: a foreign key constraint fails (`socialnetworking_development`.`posts`, CONSTRAINT `fk_rails_cd61a4aa45` FOREIGN KEY (`user_id`) REFERENCES `profiles` (`id`)): 

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment