From d2998764c5ec6f84f55a1a27e74a711c3f043d6a Mon Sep 17 00:00:00 2001 From: Zachary Scott Date: Fri, 10 Apr 2015 17:27:40 -0700 Subject: Copy edits for primary_key documentation in association guide. [ci skip] --- guides/source/association_basics.md | 7 ++++--- 1 file 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` -- cgit v1.2.3