aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-20 18:24:36 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-20 18:24:36 +0530
commit223e2a2709cbd0013d51b024bb4e0f950586c125 (patch)
tree9f9cdf45c654527f9bb7565d91701a5720c4a71d
parent2493229674ba2e8736901d44abe0c82e6ac82993 (diff)
downloadrails-223e2a2709cbd0013d51b024bb4e0f950586c125.tar.gz
rails-223e2a2709cbd0013d51b024bb4e0f950586c125.tar.bz2
rails-223e2a2709cbd0013d51b024bb4e0f950586c125.zip
Remove Base.delete as it's same as Relation#delete
-rwxr-xr-xactiverecord/lib/active_record/base.rb26
-rw-r--r--activerecord/lib/active_record/relation.rb20
2 files changed, 21 insertions, 25 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 2629abe778..b79e768d21 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -556,7 +556,7 @@ module ActiveRecord #:nodoc:
end
alias :colorize_logging= :colorize_logging
- delegate :find, :first, :last, :all, :destroy_all, :exists?, :to => :scoped
+ delegate :find, :first, :last, :all, :destroy_all, :exists?, :delete, :to => :scoped
delegate :select, :group, :order, :limit, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :to => :scoped
delegate :count, :average, :minimum, :maximum, :sum, :calculate, :to => :scoped
@@ -646,30 +646,6 @@ module ActiveRecord #:nodoc:
end
end
- # Deletes the row with a primary key matching the +id+ argument, using a
- # SQL +DELETE+ statement, and returns the number of rows deleted. Active
- # Record objects are not instantiated, so the object's callbacks are not
- # executed, including any <tt>:dependent</tt> association options or
- # Observer methods.
- #
- # You can delete multiple rows at once by passing an Array of <tt>id</tt>s.
- #
- # Note: Although it is often much faster than the alternative,
- # <tt>#destroy</tt>, skipping callbacks might bypass business logic in
- # your application that ensures referential integrity or performs other
- # essential jobs.
- #
- # ==== Examples
- #
- # # Delete a single row
- # Todo.delete(1)
- #
- # # Delete multiple rows
- # Todo.delete([2,3,4])
- def delete(id_or_array)
- scoped.delete(id_or_array)
- end
-
# Destroy an object (or multiple objects) that has the given id, the object is instantiated first,
# therefore all callbacks and filters are fired off before the object is deleted. This method is
# less efficient than ActiveRecord#delete but allows cleanup methods and other actions to be run.
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 8942690b49..217fbb2ff4 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -123,6 +123,26 @@ module ActiveRecord
arel.delete.tap { reset }
end
+ # Deletes the row with a primary key matching the +id+ argument, using a
+ # SQL +DELETE+ statement, and returns the number of rows deleted. Active
+ # Record objects are not instantiated, so the object's callbacks are not
+ # executed, including any <tt>:dependent</tt> association options or
+ # Observer methods.
+ #
+ # You can delete multiple rows at once by passing an Array of <tt>id</tt>s.
+ #
+ # Note: Although it is often much faster than the alternative,
+ # <tt>#destroy</tt>, skipping callbacks might bypass business logic in
+ # your application that ensures referential integrity or performs other
+ # essential jobs.
+ #
+ # ==== Examples
+ #
+ # # Delete a single row
+ # Todo.delete(1)
+ #
+ # # Delete multiple rows
+ # Todo.delete([2,3,4])
def delete(id_or_array)
where(@klass.primary_key => id_or_array).delete_all
end