Re: [Rails] rails still looking for old foreign key after removing a model

15 views
Skip to first unread message

Hassan Schroeder

unread,
Jun 11, 2017, 11:08:30 AM6/11/17
to rubyonrails-talk
On Sat, Jun 10, 2017 at 6:50 PM, fugee ohu <fuge...@gmail.com> wrote:

> ... so I took out the Profile model

What does "took out" mean? What exactly did you do? Is it the
exact reverse of how you created that model to start with?

> 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`)):

Given that you're seeing a *database-generated* error -- have you
looked at the relationships, i.e. foreign keys, in the referenced tables
in that database?

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote
Reply all
Reply to author
Forward
0 new messages