# Problems with destroy action

**URL:** <https://www.ruby-forum.com/t/problems-with-destroy-action/90192>\
**Category:** Rails\
**Created:** [March 26, 2007, 7:26pm UTC](https://www.ruby-forum.com/t/problems-with-destroy-action/90192 "2007-03-26T19:26:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaSSS\_lo\_Geyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@PaSSS\_lo\_Geyer](https://www.ruby-forum.com/u/PaSSS_lo_Geyer)\
**Post date:** [March 26, 2007, 7:26pm UTC](https://www.ruby-forum.com/t/problems-with-destroy-action/90192/1 "2007-03-26T19:26:56Z")

</div>

i was trying to destroy an item from my database using charges/destroy  
action, and i get this message:

Processing ChargesController#destroy (for 127.0.0.1 at 2007-03-26  
14:20:00) [GET]  
Session ID: f7b10d423fe59d16286c3ccb2a436225  
Parameters: {“action”=\>“destroy”, “id”=\>“3”,  
“controller”=\>“charges”}  
User Load (0.001144) SELECT \* FROM users WHERE (users.“id” = 1)  
LIMIT 1  
Redirected to [http://clovisgeyer.auszug.ath.cx:1337/charges/list](http://clovisgeyer.auszug.ath.cx:1337/charges/list)  
Filter chain halted as  
[#\<ActionController::Filters::ClassMethods::ProcFilter:0x2adaaef03f30  
@filter=#\<Proc:0x00002adaaefa7270@/usr/lib/ruby/gems/1.8/gems/  
actionpack-1.13.2/lib/action\_controller/verification.rb:74\>\>] returned  
false.  
Completed in 0.26078 (3 reqs/sec) | DB: 0.00114 (0%) | 302 Found  
[[http://clovisgeyer.auszug.ath.cx/charges/destroy/3](http://clovisgeyer.auszug.ath.cx/charges/destroy/3)]

anyone already had any problem like this?

---

<div class="post-metadata">

**Author:** ![PaSSS\_lo\_Geyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@PaSSS\_lo\_Geyer](https://www.ruby-forum.com/u/PaSSS_lo_Geyer)\
**Post date:** [March 26, 2007, 7:43pm UTC](https://www.ruby-forum.com/t/problems-with-destroy-action/90192/2 "2007-03-26T19:43:09Z")

</div>

Hi Paulo,

Paulo Geyer wrote:

> i was trying to destroy an item from my database  
> using charges/destroy action, and i get this message:
> 
> Processing ChargesController#destroy (for 127.0.0.1 at 2007-03-26  
> 14:20:00) [GET]  
> …  
> Redirected to [http://clovisgeyer.auszug.ath.cx:1337/charges/list](http://clovisgeyer.auszug.ath.cx:1337/charges/list)

Your destroy action is being invoked via a GET. That’s dangerous.  
Rails  
tried to help protect you from making this ‘mistake’ and included the  
following in your controller.

# GETs should be safe (see

[URIs, Addressability, and the use of HTTP GET and POST](http://www.w3.org/2001/tag/doc/whenToUseGet.html))  
verify :method =\> :post, :only =\> [:destroy, :create, :update],  
:redirect\_to =\> { :action =\> :list }

You can take the verify out if you choose to take that risk. Better  
yet,  
change the link in the view that’s invoking the destroy action to use  
the  
POST method.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![PaSSS\_lo\_Geyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@PaSSS\_lo\_Geyer](https://www.ruby-forum.com/u/PaSSS_lo_Geyer)\
**Post date:** [March 26, 2007, 7:51pm UTC](https://www.ruby-forum.com/t/problems-with-destroy-action/90192/3 "2007-03-26T19:51:11Z")

</div>

i’ve tried “:method =\> :delete” but didn’t work, the correct method  
should be :delete, no?

but it works with :post method  
thanks Bill!
