Skip to content

Commit

Permalink
remove references to :finder_sql, :counter_sql, :delete_sql, :insert_…
Browse files Browse the repository at this point in the history
…sql from guides
  • Loading branch information
jonleighton committed Jul 20, 2012
1 parent ac48b62 commit df0b7a8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 55 deletions.
22 changes: 1 addition & 21 deletions guides/source/active_support_core_extensions.textile
Original file line number Diff line number Diff line change
Expand Up @@ -2783,27 +2783,7 @@ The method +assert_valid_keys+ receives an arbitrary number of arguments, and ch
{:a => 1}.assert_valid_keys("a") # ArgumentError
</ruby>

Active Record does not accept unknown options when building associations for example. It implements that control via +assert_valid_keys+:

<ruby>
mattr_accessor :valid_keys_for_has_many_association
@@valid_keys_for_has_many_association = [
:class_name, :table_name, :foreign_key, :primary_key,
:dependent,
:select, :conditions, :include, :order, :group, :having, :limit, :offset,
:as, :through, :source, :source_type,
:uniq,
:finder_sql, :counter_sql,
:before_add, :after_add, :before_remove, :after_remove,
:extend, :readonly,
:validate, :inverse_of
]

def create_has_many_reflection(association_id, options, &extension)
options.assert_valid_keys(valid_keys_for_has_many_association)
...
end
</ruby>
Active Record does not accept unknown options when building associations, for example. It implements that control via +assert_valid_keys+.

NOTE: Defined in +active_support/core_ext/hash/keys.rb+.

Expand Down
34 changes: 0 additions & 34 deletions guides/source/association_basics.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down Expand Up @@ -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+.
Expand All @@ -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:
Expand Down Expand Up @@ -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+
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down

0 comments on commit df0b7a8

Please sign in to comment.