From 648b8fda54e5de742e4ffbb4bc8e6edf0b68a111 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson <david@loudthinking.com>
Date: Fri, 17 Dec 2004 21:36:13 +0000
Subject: Added Base.destroy and Base.delete to remove records without holding
 a reference to them first.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@206 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
---
 activerecord/lib/active_record/base.rb | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'activerecord/lib')

diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index ca586aacad..2bcea9dd5d 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -333,6 +333,16 @@ module ActiveRecord #:nodoc:
         object
       end
 
+      # Deletes the record with the given +id+ without instantiating an object first.
+      def delete(id)
+        delete_all([ "#{primary_key} = ?", id ])
+      end
+      
+      # Destroys the record with the given +id+ by instantiating the object and calling #destroy (all the callbacks are the triggered).
+      def destroy(id)
+        find(id).destroy
+      end
+
       # Updates all records with the SET-part of an SQL update statement in +updates+. A subset of the records can be selected 
       # by specifying +conditions+. Example:
       #   Billing.update_all "category = 'authorized', approved = 1", "author = 'David'"
-- 
cgit v1.2.3