# Help selecting the correct elements in an array

**URL:** <https://discuss.rubyonrails.org/t/help-selecting-the-correct-elements-in-an-array/55545>\
**Category:** rubyonrails-talk\
**Created:** [November 5, 2010, 4:19am UTC](https://discuss.rubyonrails.org/t/help-selecting-the-correct-elements-in-an-array/55545 "2010-11-05T04:19:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_demetriusolsen](https://avatars.discourse-cdn.com/v4/letter/_/d9b06d/32.png) [@\_demetriusolsen](https://discuss.rubyonrails.org/u/_demetriusolsen)\
**Post date:** [November 5, 2010, 4:19am UTC](https://discuss.rubyonrails.org/t/help-selecting-the-correct-elements-in-an-array/55545/1 "2010-11-05T04:19:11Z")

</div>

I'm working on a method but the results are "the opposite" of what I want to happen. Here's what I have in my model:

after\_update :foo

&nbsp;&nbsp;def foo &nbsp;&nbsp;&nbsp;&nbsp;self.scores.where(:standard\_id =\> self.standard\_ids).each do | score\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;score.destroy &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end

... which actually deletes the scores I want to keep. What I want to do is something like:

self.scores - self.scores.where(:standard\_id =\> self.standard\_ids).each do...

OR

a = self.scores b = self.scores.where(:standard\_id =\> self.standard\_ids) a - b = c c.each do...

OR

self.scores.reject(self.scores.where(:standard\_id =\> self.standard\_ids)).each do...

Any help is greatly appreciated! Thanks in advance 🙂
