aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2007-12-05 15:15:56 +0000
committerMarcel Molina <marcel@vernix.org>2007-12-05 15:15:56 +0000
commit6a45e01b3262a5d6b07535c872fdc74d3abad8c0 (patch)
treee13d06894ab9003a4ddf4eaeae941a8e8cbf7fd8 /activerecord/lib/active_record/base.rb
parented69b38afaa5a4703864dc007399ab05613bb5d2 (diff)
downloadrails-6a45e01b3262a5d6b07535c872fdc74d3abad8c0.tar.gz
rails-6a45e01b3262a5d6b07535c872fdc74d3abad8c0.tar.bz2
rails-6a45e01b3262a5d6b07535c872fdc74d3abad8c0.zip
Document options and add examples for delete. Closes #7986 [fearoffish]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8292 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 7e2d93202f..19077920ff 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -509,8 +509,24 @@ module ActiveRecord #:nodoc:
end
end
- # Deletes the record with the given +id+ without instantiating an object first. If an array of ids is provided, all of them
- # are deleted.
+ # Delete an object (or multiple objects) where the +id+ given matches the primary_key. A SQL +DELETE+ command
+ # is executed on the database which means that no callbacks are fired off running this. This is an efficient method
+ # of deleting records that don't need cleaning up after or other actions to be taken.
+ #
+ # Objects are _not_ instantiated with this method.
+ #
+ # ==== Options
+ #
+ # +id+ Can be either an Integer or an Array of Integers
+ #
+ # ==== Examples
+ #
+ # # Delete a single object
+ # Todo.delete(1)
+ #
+ # # Delete multiple objects
+ # todos = [1,2,3]
+ # Todo.delete(todos)
def delete(id)
delete_all([ "#{connection.quote_column_name(primary_key)} IN (?)", id ])
end