From 464d47eaaf76995ae8eaa5205d250ff859fed795 Mon Sep 17 00:00:00 2001 From: Rohit Paul Kuruvilla Date: Tue, 21 Jan 2014 23:07:18 +0530 Subject: Updated association_basics.md [ci skip] Updated association_basics.md to include how to write migrations for self joins Update association_basics.md Corrected the update Update association_basics.md Typo fix Changed :employee to :manager --- guides/source/association_basics.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'guides/source') diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index 9867d2dc3f..5ec6ae0f21 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -490,6 +490,19 @@ end With this setup, you can retrieve `@employee.subordinates` and `@employee.manager`. +In your migrations/schema, you will add a references column to the model itself. + +```ruby +class CreateEmployees < ActiveRecord::Migration + def change + create_table :employees do |t| + t.references :manager + t.timestamps + end + end +end +``` + Tips, Tricks, and Warnings -------------------------- -- cgit v1.2.3