add associations to exisiting models
问题 I'm wondering how I can add associations to my models. Suppose, I generate 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 end class Car < ActiveRecord::Base belongs_to :user end The question is: how to apply this modification by migrations in order to obtain cars_users table in the database? I'm planning to use that table in my code. 回答1: belongs_to association