title: How to generate associations between models
body: <p>I am wondering how to do the association in Rails correct. First I create a City model and an Organisation. Now I want to have an Organisation have a City... this is done by adding the <code>has_many</code> and <code>has_one</code> associations. After that I run <code>rake db:migrate</code>. But somehow it does not create a field <code>city</code> or <code>city_id</code> in my database model. Do I have to do this myself? Shouldn't rails now create a foreign key constraint in the database?</p>
  
  <p>To see if it has worked I am using <code>rails c</code> and type in <code>Organisation</code>
  the answer is the following:</p>
  
  <pre><code>=&gt; Organisation(id: integer, name: string, description: string, url: string, created_at: datetime, updated_at: datetime) 
  </code></pre>
  
  <p>Please excuse my stupid question... I am a beginner in Rails and everything is still very unfamiliar.</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>City:</p>
  
  <pre><code>class City &lt; ActiveRecord::Base
    has_many :organisations
  end
  </code></pre>
  
  <p>Organisation:</p>
  
  <pre><code>class Organisation &lt; ActiveRecord::Base
    has_one :city
  end
  </code></pre>
  
  <p>Create City:</p>
  
  <pre><code>class CreateCities &lt; ActiveRecord::Migration
    def change
      create_table :cities do |t|
        t.string :name
        t.string :country
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>Create Organisation:</p>
  
  <pre><code>class CreateOrganisations &lt; ActiveRecord::Migration
    def change
      create_table :organisations do |t|
        t.string :name
        t.string :description
        t.string :url
  
        t.timestamps
      end
    end
  end
  </code></pre>