Forum: Ruby on Rails Undefined method "add_reference"

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Alex S. (Guest)
on 2008-11-19 00:17

I try to add a foreign key in one of my rails migrations in the
following way:

def self.up
         add_reference :categories, :items

This, strangely, leads to the following error during the migration:

-- add_reference(:categories, :items)
rake aborted!
undefined method `add_reference' for #

In the same way fails the code:

def self.up
  change_table :categories do |t|
      t.references :items

I recently upgraded to Rails 2.1.2, if this is relevant to my case. Does
anyone have any pointers on how to solve this problem?

Thanks in advance!
This topic is locked and can not be replied to.