I\'m new to Rails, and I\'m coming to it from a Django background. I\'ve come to terms with the fact that models and the database schema are separate in Rails, online Django
You have to add the foreign key in your migration file, something like this:
def change
create_table :songs do |t|
t.references :artist
end
add_index :songs, :artist_id
end
Now, in Rails 4 you can do:
class AddProcedureIdToUser < ActiveRecord::Migration
def change
add_reference :users, :procedure, index: true
end
end
to an existing Model
You can generate migration
rails g migration AddProcedureIdToUser procedure:references
Thanks