aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--guides/source/association_basics.md7
1 files changed, 4 insertions, 3 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index b33e5d03f7..d8dcf75740 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -916,9 +916,10 @@ TIP: In any case, Rails will not create foreign key columns for you. You need to
##### `:primary_key`
-By convention, Rails assumes that the column used to hold the primary key of it's table is `id`, and `:primary_key` allows you to specify a different column.
+By convention, Rails assumes that the `id` column is used to hold the primary key of it's table.
+The `:primary_key` option allows you to specify a different column.
-Let's say that `users` table has `guid` as the primary key. And the requirement is that `todos` table should hold `guid` column value in the foreign key `user_id`. This can be achieved like this
+For example, given we have a `users` table with `guid` as the primary key. If we want a separate `todos` table to hold the foreign key `user_id` in the `guid` column, then we can use `primary_key` to achieve this like so:
```ruby
class User < ActiveRecord::Base
@@ -930,7 +931,7 @@ class Todo < ActiveRecord::Base
end
```
-Now if we execute `@user.todos.create` then `@todo` record will have `user_id` value as the `guid` value of `@user`.
+When we execute `@user.todos.create` then the `@todo` record will have `user_id` value as the `guid` value of `@user`.
##### `:inverse_of`