diff options
Diffstat (limited to 'guides/source/association_basics.textile')
-rw-r--r-- | guides/source/association_basics.textile | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/guides/source/association_basics.textile b/guides/source/association_basics.textile index 8ddc56bef1..4dca7a508c 100644 --- a/guides/source/association_basics.textile +++ b/guides/source/association_basics.textile @@ -1257,10 +1257,8 @@ The +has_many+ association supports these options: * +:autosave+ * +:class_name+ * +:conditions+ -* +:counter_sql+ * +:dependent+ * +:extend+ -* +:finder_sql+ * +:foreign_key+ * +:group+ * +:include+ @@ -1326,12 +1324,6 @@ class Customer < ActiveRecord::Base end </ruby> -h6(#has_many-counter_sql). +:counter_sql+ - -Normally Rails automatically generates the proper SQL to count the association members. With the +:counter_sql+ option, you can specify a complete SQL statement to count them yourself. - -NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL will be generated by substituting the +SELECT ... FROM+ clause of your +:finder_sql+ statement by +SELECT COUNT(*) FROM+. - h6(#has_many-dependent). +:dependent+ If you set the +:dependent+ option to +:destroy+, then deleting this object will call the +destroy+ method on the associated objects to delete those objects. If you set the +:dependent+ option to +:delete_all+, then deleting this object will delete the associated objects _without_ calling their +destroy+ method. If you set the +:dependent+ option to +:nullify+, then deleting this object will set the foreign key in the associated objects to +NULL+. @@ -1345,10 +1337,6 @@ h6(#has_many-extend). +:extend+ The +:extend+ option specifies a named module to extend the association proxy. Association extensions are discussed in detail <a href="#association-extensions">later in this guide</a>. -h6(#has_many-finder_sql). +:finder_sql+ - -Normally Rails automatically generates the proper SQL to fetch the association members. With the +:finder_sql+ option, you can specify a complete SQL statement to fetch them yourself. If fetching objects requires complex multi-table SQL, this may be necessary. - h6(#has_many-foreign_key). +:foreign_key+ By convention, Rails assumes that the column used to hold the foreign key on the other model is the name of this model with the suffix +_id+ added. The +:foreign_key+ option lets you set the name of the foreign key directly: @@ -1700,14 +1688,10 @@ The +has_and_belongs_to_many+ association supports these options: * +:autosave+ * +:class_name+ * +:conditions+ -* +:counter_sql+ -* +:delete_sql+ * +:extend+ -* +:finder_sql+ * +:foreign_key+ * +:group+ * +:include+ -* +:insert_sql+ * +:join_table+ * +:limit+ * +:offset+ @@ -1767,24 +1751,10 @@ end If you use a hash-style +:conditions+ option, then record creation via this association will be automatically scoped using the hash. In this case, using +@parts.assemblies.create+ or +@parts.assemblies.build+ will create orders where the +factory+ column has the value "Seattle". -h6(#has_and_belongs_to_many-counter_sql). +:counter_sql+ - -Normally Rails automatically generates the proper SQL to count the association members. With the +:counter_sql+ option, you can specify a complete SQL statement to count them yourself. - -NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL will be generated by substituting the +SELECT ... FROM+ clause of your +:finder_sql+ statement by +SELECT COUNT(*) FROM+. - -h6(#has_and_belongs_to_many-delete_sql). +:delete_sql+ - -Normally Rails automatically generates the proper SQL to remove links between the associated classes. With the +:delete_sql+ option, you can specify a complete SQL statement to delete them yourself. - h6(#has_and_belongs_to_many-extend). +:extend+ The +:extend+ option specifies a named module to extend the association proxy. Association extensions are discussed in detail <a href="#association-extensions">later in this guide</a>. -h6(#has_and_belongs_to_many-finder_sql). +:finder_sql+ - -Normally Rails automatically generates the proper SQL to fetch the association members. With the +:finder_sql+ option, you can specify a complete SQL statement to fetch them yourself. If fetching objects requires complex multi-table SQL, this may be necessary. - h6(#has_and_belongs_to_many-foreign_key). +:foreign_key+ By convention, Rails assumes that the column in the join table used to hold the foreign key pointing to this model is the name of this model with the suffix +_id+ added. The +:foreign_key+ option lets you set the name of the foreign key directly: @@ -1811,10 +1781,6 @@ h6(#has_and_belongs_to_many-include). +:include+ You can use the +:include+ option to specify second-order associations that should be eager-loaded when this association is used. -h6(#has_and_belongs_to_many-insert_sql). +:insert_sql+ - -Normally Rails automatically generates the proper SQL to create links between the associated classes. With the +:insert_sql+ option, you can specify a complete SQL statement to insert them yourself. - h6(#has_and_belongs_to_many-join_table). +:join_table+ If the default name of the join table, based on lexical ordering, is not what you want, you can use the +:join_table+ option to override the default. |