title: t.belongs_to and the effect on postgresql DB
body: <pre><code>class CreateCustomers &lt; ActiveRecord::Migration
    def change
      create_table :customers do |t|
        t.belongs_to :user
        t.string :firstname
        t.string :surname
        t.timestamps
      end
    end
  </code></pre>
  
  <p>These are my models:</p>
  
  <pre><code>class Customer &lt; ActiveRecord::Base
      belongs_to :user
  end
  
  class User &lt; ActiveRecord::Base
    has_many :customers
  end
  </code></pre>
  
  <p>Found the  <code>t.belongs_to :user</code> to add a foreign key in the database.
  But when I check up my postgre database with pgadminIII, there is no foreign_key listed.
  The migration adds the user_id as it should, but no foreign_key listed.</p>
  
  <p>Any explanation for that?</p>
  
  <p>best regards
  denym</p>
  
  <p>Edit: More information on the <code>t.belongs_to</code></p>
  
  <pre><code>create_table :accounts do |t|
    t.belongs_to :supplier
    t.string :account_number
    t.timestamps
  end
  </code></pre>
  
  <p>This is one example of it. From the railsguide ebook chapter 2.</p>