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:
parent
b0a8ef140e
commit
464d47eaaf
1 changed files with 13 additions and 0 deletions
|
@ -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
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue