Whenever you make a migration to add a foreign key, you should also add an index for it
Copy def self.up add_column :comments, :user_id, :integer add_index :comments, :user_id end
def self.up add_column :comments, :user_id, :integer add_index :comments, :user_id end