# Model.destroy(array of ids) Bug

**URL:** <https://www.ruby-forum.com/t/model-destroy-array-of-ids-bug/172363>\
**Category:** Rails\
**Created:** [July 20, 2009, 10:00am UTC](https://www.ruby-forum.com/t/model-destroy-array-of-ids-bug/172363 "2009-07-20T10:00:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![san2821](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@san2821](https://www.ruby-forum.com/u/san2821)\
**Post date:** [July 20, 2009, 10:00am UTC](https://www.ruby-forum.com/t/model-destroy-array-of-ids-bug/172363/1 "2009-07-20T10:00:29Z")

</div>

Hello friends !

Model.destroy(array of ids) gives record not found error in Internet  
Explorer.

Sandip R~

–  
Ruby on Rails Developer

> **[Blogs - Neuigkeiten - Artikel - Webseiten - Medien](https://www.sosblog.com/)**
>
> Auf SOSblog geht es um aktuelle Blogs, Neuigkeiten, Artikel, Webseiten und Medien. Wir bringen interessante neue Webseiten aus den Tiefen des Webs.

> **[Judul Situs](https://funonrails.wordpress.com)**
>
> “Cinta tidak mengenal batas. Cinta mampu melewati rintangan, melompati pagar, menembus dinding untuk mencapai tujuannya dengan penuh harapan.” — Maya Angelou

> **[Josh Software | Custom Software Development Services & Solutions](https://joshsoftware.com/)**
>
> JoshSoftware offers custom software development Services & Solution that provides enterprise, software development services for web & mobile.

---

<div class="post-metadata">

**Author:** ![san2821](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@san2821](https://www.ruby-forum.com/u/san2821)\
**Post date:** [July 20, 2009, 10:54am UTC](https://www.ruby-forum.com/t/model-destroy-array-of-ids-bug/172363/2 "2009-07-20T10:54:14Z")

</div>

Sandip,

Are you certain all of the ids are valid?

You could try adding something like this to your controller action  
before the destroy is called:

def destroy  
@records = Model.all( :conditions =\> [“id IN (?)”, array])  
raise “Not all ids were valid!” unless @records.size == array.size  
Model.destroy(array)  
…  
end

This will raise an error if the ids are not all valid and you’ll know  
to look elsewhere for the root of the problem

Hope that helps?

Gavin

> **[Ruby on Rails tips & Tutorials](https://handyrailstips.com/)**
>
> Ruby on Rails tips and tutorials

---

<div class="post-metadata">

**Author:** ![san2821](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@san2821](https://www.ruby-forum.com/u/san2821)\
**Post date:** [July 20, 2009, 2:28pm UTC](https://www.ruby-forum.com/t/model-destroy-array-of-ids-bug/172363/3 "2009-07-20T14:28:45Z")

</div>

Sorry, my mistake !

Actually IE brawser was submitting request twice to delete action.  
hence…in second request it was showing record not found exception.

–Sandip R~
