# Destroy action not being invoked

**URL:** <https://www.ruby-forum.com/t/destroy-action-not-being-invoked/142841>\
**Category:** Rails\
**Created:** [July 12, 2008, 12:14am UTC](https://www.ruby-forum.com/t/destroy-action-not-being-invoked/142841 "2008-07-12T00:14:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 12, 2008, 12:14am UTC](https://www.ruby-forum.com/t/destroy-action-not-being-invoked/142841/1 "2008-07-12T00:14:26Z")

</div>

This is my index:

```
<td><%= link_to 'Remove', user,
    :class => "list-actions", :confirm => 'Are you sure?',
    :method => :delete %></td>

```

And this is my controller:

def destroy  
@user = User.find(params[:id])  
@user.destroy

```
respond_to do |format|
  format.html { redirect_to(users_url) }
  format.xml { head :ok }
end

```

end

For some reason, when I click on the ‘Remove’ link, it directs me to the  
‘Show’ action and does not destroy the item… strange ??

Thanks

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 12, 2008, 2:36am UTC](https://www.ruby-forum.com/t/destroy-action-not-being-invoked/142841/2 "2008-07-12T02:36:31Z")

</div>

Hi Justin,

Justin To wrote:

> For some reason, \<…\>

The reason would be found in routes.rb. You can experiment, to good  
effect,  
with script/console.

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [July 20, 2008, 6:39pm UTC](https://www.ruby-forum.com/t/destroy-action-not-being-invoked/142841/3 "2008-07-20T18:39:24Z")

</div>

Quoting Justin To [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> @user = User.find(params[:id])
> @user.destroy
> 
> respond_to do |format|
> format.html { redirect_to(users_url) }
> format.xml { head :ok }
> end
> 
> ```
> 
> end
> 
> For some reason, when I click on the ‘Remove’ link, it directs me to the  
> ‘Show’ action and does not destroy the item… strange ??

The delete action/method does not invoke the destroy method. If you  
want  
destroy, put it in the link. Unless you explicitly it in  
config/routes.rb.

HTH,  
Jeffrey
