From d83eda9b696f2e51c0c79dfd028b8b2d20160426 Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Wed, 29 Oct 2008 08:16:40 -0500 Subject: Clarify use of :select on :belongs_to in AR Associations Guide --- railties/doc/guides/html/association_basics.html | 8 ++++++++ railties/doc/guides/source/association_basics.txt | 2 ++ 2 files changed, 10 insertions(+) (limited to 'railties/doc/guides') diff --git a/railties/doc/guides/html/association_basics.html b/railties/doc/guides/html/association_basics.html index 96aae9c51a..9159eaab2a 100644 --- a/railties/doc/guides/html/association_basics.html +++ b/railties/doc/guides/html/association_basics.html @@ -1185,6 +1185,14 @@ http://www.gnu.org/software/src-highlite -->

If you set the :readonly option to true, then the associated object will be read-only when retrieved via the association.

:select

The :select option lets you override the SQL SELECT clause that is used to retrieve data about the associated object. By default, Rails retrieves all columns.

+
+ + + +
+Tip +If you set the :select option on a belongs_to association, you should also set the foreign_key option to guarantee the correct results.
+
:validate

If you set the :validate option to true, then associated objects will be validated whenever you save this object. By default, this is false: associated objects will not be validated when this object is saved.

4.1.3. When are Objects Saved?

diff --git a/railties/doc/guides/source/association_basics.txt b/railties/doc/guides/source/association_basics.txt index 7ab42dafbe..5ba616642b 100644 --- a/railties/doc/guides/source/association_basics.txt +++ b/railties/doc/guides/source/association_basics.txt @@ -765,6 +765,8 @@ If you set the +:readonly+ option to +true+, then the associated object will be The +:select+ option lets you override the SQL +SELECT+ clause that is used to retrieve data about the associated object. By default, Rails retrieves all columns. +TIP: If you set the +:select+ option on a +belongs_to+ association, you should also set the +foreign_key+ option to guarantee the correct results. + ===== +:validate+ If you set the +:validate+ option to +true+, then associated objects will be validated whenever you save this object. By default, this is +false+: associated objects will not be validated when this object is saved. -- cgit v1.2.3