diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-01 00:13:38 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-01 00:17:40 +0530 |
commit | d5f9173926598ace058b502e00c49f6477820509 (patch) | |
tree | 331489c4d5e4fbb0efb97e442ac366e8837a7d70 /activerecord/lib/active_record/base.rb | |
parent | ea41a757aab86206278b99deb86e93a760833819 (diff) | |
download | rails-d5f9173926598ace058b502e00c49f6477820509.tar.gz rails-d5f9173926598ace058b502e00c49f6477820509.tar.bz2 rails-d5f9173926598ace058b502e00c49f6477820509.zip |
Add Relation#delete [Pratik Naik, Emilio Tagua]
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c4bdbdad08..de320475e8 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -815,8 +815,8 @@ module ActiveRecord #:nodoc: # # # Delete multiple rows # Todo.delete([2,3,4]) - def delete(id) - delete_all([ "#{connection.quote_column_name(primary_key)} IN (?)", id ]) + def delete(id_or_array) + arel_table.where(construct_conditions(nil, scope(:find))).delete(id_or_array) end # Destroy an object (or multiple objects) that has the given id, the object is instantiated first, @@ -2323,7 +2323,7 @@ module ActiveRecord #:nodoc: # be made (since they can't be persisted). def destroy unless new_record? - self.class.arel_table.where(self.class.arel_table[self.class.primary_key].eq(id)).delete + self.class.arel_table.where(self.class.arel_table[self.class.primary_key].eq(id)).delete_all end @destroyed = true |