diff options
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 10 |
1 files changed, 10 insertions, 0 deletions
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'" |