Say you have these two models
rails generate model User
rails generate model Car
Now I want to add an associations so that the models acquire the form
class User < ActiveRecord::Base
has_many :cars
en
class Car < ActiveRecord::Base
belongs_to :driver, foreign_key: "driver_id", class_name: "User"
end
What will my migrations look like to add the proper column to car? Should it be a column named driver_id or user_id?
This is a variation on this question.