Browse files

Add note about Rails 4.0 changes

  • Loading branch information...
1 parent 910f7aa commit abcaa9be82277f96e7ddeaf4e32e6efb39edec02 @asanghi asanghi committed Feb 18, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 railties/guides/source/association_basics.textile
View
4 railties/guides/source/association_basics.textile
@@ -901,6 +901,8 @@ h6(#has_one-dependent). +:dependent+
If you set the +:dependent+ option to +:destroy+, then deleting this object will call the +destroy+ method on the associated object to delete that object. If you set the +:dependent+ option to +:delete+, then deleting this object will delete the associated object _without_ calling its +destroy+ method. If you set the +:dependent+ option to +:nullify+, then deleting this object will set the foreign key in the association object to +NULL+.
If you set the +:dependent+ option to +:restrict+, then the deletion of the object is restricted if a dependent associated object exist and an error is added to the base model.
+NOTE: Before Rails 4.0, using +:restrict+ with +:dependent: option used to raise a +DeleteRestrictionError+. This functionality has since been deprecated. If your code still depends on the exception being raised, then you should add the +:config.active_record.dependent_restrict_raises = true+ to your application config.
+
h6(#has_one-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:
@@ -1252,6 +1254,8 @@ If you set the +:dependent+ option to +:restrict+, then the deletion of the obje
NOTE: This option is ignored when you use the +:through+ option on the association.
+NOTE: Before Rails 4.0, using +:restrict+ with +:dependent: option used to raise a +DeleteRestrictionError+. This functionality has since been deprecated. If your code still depends on the exception being raised, then you should add the +:config.active_record.dependent_restrict_raises = true+ to your application config.
+
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>.

0 comments on commit abcaa9b

Please sign in to comment.