# Destroy problem

**URL:** <https://www.ruby-forum.com/t/destroy-problem/173569>\
**Category:** Rails\
**Created:** [August 11, 2009, 3:23pm UTC](https://www.ruby-forum.com/t/destroy-problem/173569 "2009-08-11T15:23:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 3:23pm UTC](https://www.ruby-forum.com/t/destroy-problem/173569/1 "2009-08-11T15:23:35Z")

</div>

i have table pro\_categories and i am handle add update from admins  
controller but can not destroy record from there i mean using admin  
controller

### Product Category

```
</tr>
<% @pro_categories.each do |p| %>
<tr align="center">
  <td><%= p.pcate_name%></td>

  <td><%= link_to_remote('Show',:update => "mcont", :url =>

```

# {:controller =\> :admins, :action =\> :cateshow},:with =\> “‘id=#{p.id}’”)%\>

```
<td><%= link_to 'Destroy', p, :confirm => 'Are you sure?', :method

```

# =\> :delete %\>

```
</tr>
<%end%>
<tr><td colspan="3" align="center"><%= link_to_remote('New',:update

```

=\> “mcont”, :url =\> {:controller =\> :admins, :action =\> :cateadd }  
)%\>&nbsp;&nbsp;\<%= link\_to ‘Back’,admins\_path %\>

| Category Title | \<%= link\_to\_remote(‘Edit’,:update =\> “mcont”, :url =\>  
{:controller =\> :admins, :action =\> :catedit},:with =\> “‘id=#{p.id}’”)  
%\> |

above my file i am display record using pro\_categories table so it’s  
controller p define

if any idea about it i want to delete record in p(pro\_categories) table

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 3:44pm UTC](https://www.ruby-forum.com/t/destroy-problem/173569/2 "2009-08-11T15:44:47Z")

</div>

On Aug 11, 2:23 pm, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> i have table pro\_categories and i am handle add update from admins  
> controller but can not destroy record from there i mean using admin  
> controller

What happens when you try ?

Fred

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 3:49pm UTC](https://www.ruby-forum.com/t/destroy-problem/173569/3 "2009-08-11T15:49:05Z")

</div>

Frederick C. wrote:

> On Aug 11, 2:23ï¿½pm, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > i have table pro\_categories and i am handle add update from admins  
> > controller but can not destroy record from there i mean using admin  
> > controller
> 
> What happens when you try ?
> 
> Fred

it’s url is like this [http://127.0.0.1:3000/pro\_categories/1](http://127.0.0.1:3000/pro_categories/1) but i have  
no pro\_categories controller so i want to define this delete method in  
admin controller and i want to delete pro\_categories’s record.(actually  
i have procategorie model.)

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 3:55pm UTC](https://www.ruby-forum.com/t/destroy-problem/173569/4 "2009-08-11T15:55:54Z")

</div>

On Aug 11, 2:49 pm, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> it’s url is like thishttp://127.0.0.1:3000/pro\_categories/1but i have  
> no pro\_categories controller so i want to define this delete method in  
> admin controller and i want to delete pro\_categories’s record.(actually  
> i have procategorie model.)

either fiddle with your routes so that you have an admin namespace (so  
that you can do stuff like link\_to ‘destroy’, admin\_product\_path  
(p), …) or don’t use the restful stuff.

Fred

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 11, 2009, 4:10pm UTC](https://www.ruby-forum.com/t/destroy-problem/173569/5 "2009-08-11T16:10:06Z")

</div>

Frederick C. wrote:

> On Aug 11, 2:49ï¿½pm, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > it’s url is like thishttp://127.0.0.1:3000/pro\_categories/1but i have  
> > no pro\_categories controller so i want to define this delete method in  
> > admin controller and i want to delete pro\_categories’s record.(actually  
> > i have procategorie model.)
> 
> either fiddle with your routes so that you have an admin namespace (so  
> that you can do stuff like link\_to ‘destroy’, admin\_product\_path  
> (p), …) or don’t use the restful stuff.
> 
> Fred

ok dear i have to fix this problem

in destroy code like this  
\<%= link\_to ‘Destroy’,:confirm =\> ‘Are you sure?’,:action =\>  
‘destroycat’,:id =\> p.id, :method =\> :delete %\>

p.id it take only id only p take pro\_categories so that if we r make  
such type it is possible

and controller file like this

def destroycat  
@pro\_categorie = ProCategorie.find(params[:id])  
@pro\_categorie.destroy  
respond\_to do |format|  
format.html { redirect\_to(admins\_url) }  
format.xml { head :ok }  
end  
end
