Skip to content
Browse files

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
  • Loading branch information...
1 parent b0a8ef1 commit 464d47eaaf76995ae8eaa5205d250ff859fed795 @rohitpaulk rohitpaulk committed
Showing with 13 additions and 0 deletions.
  1. +13 −0 guides/source/association_basics.md
View
13 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
--------------------------

0 comments on commit 464d47e

Please sign in to comment.
Something went wrong with that request. Please try again.