Flowdock
references(*args) public

Adds a reference. Optionally adds a type column, if :polymorphic option is provided. references and belongs_to are acceptable.

t.references(:user)
t.belongs_to(:supplier, polymorphic: true)
Show source
Register or log in to add new notes.
August 22, 2008
4 thanks

Doesn't add an index

Typically you will want to have an index on foreign keys but this method doesn’t assume that. Outside of the create_table block you should follow this with add_index :

add_index :table_name, :goat_id
# and, if polymorphic:
add_index :table_name, :goat_type