diff options
-rw-r--r-- | activeresource/CHANGELOG | 2 | ||||
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 4 | ||||
-rw-r--r-- | activeresource/test/base_test.rb | 4 |
3 files changed, 10 insertions, 0 deletions
diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG index 94481ae9ef..def1fd8ad4 100644 --- a/activeresource/CHANGELOG +++ b/activeresource/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Add Base.delete for deleting resources without having to instantiate them first. [Jamis Buck] + * Make #save behavior mimic AR::Base#save (true on success, false on failure). [Jamis Buck] * Add Basic HTTP Authentication to ActiveResource (closes #6305). [jonathan] diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 656698fb25..40fd965487 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -81,6 +81,10 @@ module ActiveResource end end + def delete(id) + connection.delete(element_path(id)) + end + private # { :people => { :person => [ person1, person2 ] } } def find_every(options) diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb index dd017b71fa..685f9aa994 100644 --- a/activeresource/test/base_test.rb +++ b/activeresource/test/base_test.rb @@ -167,4 +167,8 @@ class BaseTest < Test::Unit::TestCase end assert_raises(ActiveResource::ResourceNotFound) { StreetAddress.find(1, :person_id => 1).destroy } end + + def test_delete + assert Person.delete(1) + end end |