1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
Rohit Paul Kuruvilla 2014-01-21 23:07:18 +05:30
parent b0a8ef140e
commit 464d47eaaf

View file

@ -490,6 +490,19 @@ end
With this setup, you can retrieve `@employee.subordinates` and `@employee.manager`. 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 Tips, Tricks, and Warnings
-------------------------- --------------------------