# Delete data from 2 different models

**URL:** <https://www.ruby-forum.com/t/delete-data-from-2-different-models/196677>\
**Category:** Rails\
**Created:** [May 9, 2008, 8:11pm UTC](https://www.ruby-forum.com/t/delete-data-from-2-different-models/196677 "2008-05-09T20:11:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RoR\_Nb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@RoR\_Nb](https://www.ruby-forum.com/u/RoR_Nb)\
**Post date:** [May 9, 2008, 8:11pm UTC](https://www.ruby-forum.com/t/delete-data-from-2-different-models/196677/1 "2008-05-09T20:11:21Z")

</div>

I’m trying to delete an account but at the same time i’d like to  
delete the portals that belongs to the account.  
This is what i wrote but it’s not working.  
how can i deal with this problem?

I have this code inside the account controller in the “destroy” method  
def destroy  
@account = Account.find(params[:id])  
@portal = Portal.find(:all, :conditions =\> [‘account\_id = ?’,  
@account.id ])  
@portal.destroy  
@account.destroy  
end  
any ideas?

the error displays this:

NoMethodError in AccountsController#destroy

undefined method `destroy' for #<Array:0x47982a0> app/controllers/accounts_controller.rb:78:in`destroy’  
Request

Parameters:

{"\_method"=\>“delete”,  
“authenticity\_token”=\>“f8c32ed76159e1b51b0883ef72a4ab801b92d322”,  
“id”=\>“11”}
