qodot
qodot

Reputation: 431

undefined method `add_foreign_key'

i installed some project in my local with git clone some_url, and i did bundle install to install gems to my local.

and to migrate cloned database, i did rake db:migrate, then i got this message.

undefined method `add_foreign_key' for #<SomeMigrationFileName:0x0000000....> ...

how can i solve this error?


ps: is it MYSQL problem? gem 'mysql2' statement exists already in my Gemfile, but when i commanded bundle install, i got a install error message during installing MYSQL.

so i install mysql with, brew install mysql

Upvotes: 1

Views: 2456

Answers (1)

Frederick Cheung
Frederick Cheung

Reputation: 84182

Foreign keys constraints are not something that rails supports out of the box (at least not until rails 4.2, which isn't out yet)

The easiest way is to use the foreigner gem which adds support for this in migrations and in schema dumping.

Upvotes: 9

Related Questions