diff options
author | Aditya Sanghi <aditya.sanghi@risingsuntech.net> | 2012-02-18 11:38:30 +0530 |
---|---|---|
committer | Aditya Sanghi <aditya.sanghi@risingsuntech.net> | 2012-02-18 11:38:30 +0530 |
commit | 910f7aab50321b2a8b347864782d8dc4f09915d8 (patch) | |
tree | 4139bb9c46e1a8e3f8c897a4b0bbb56f39ad3ed1 /railties/guides | |
parent | 3720d5ee197bea26d0719aa48c167bac4e7b0577 (diff) | |
download | rails-910f7aab50321b2a8b347864782d8dc4f09915d8.tar.gz rails-910f7aab50321b2a8b347864782d8dc4f09915d8.tar.bz2 rails-910f7aab50321b2a8b347864782d8dc4f09915d8.zip |
Add a note about :dependent => :restrict on has_one and has_many's options
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/association_basics.textile | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index a55ed38d1b..a01c24bf74 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -899,6 +899,7 @@ end 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. h6(#has_one-foreign_key). +:foreign_key+ @@ -1247,6 +1248,7 @@ NOTE: If you specify +:finder_sql+ but not +:counter_sql+, then the counter SQL 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+. +If you set the +:dependent+ option to +:restrict+, then the deletion of the object is restricted if any dependent associated objects exist and an error is added to the base model. NOTE: This option is ignored when you use the +:through+ option on the association. |