Help selecting the correct elements in an array

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

def foo
self.scores.where(:standard_id => self.standard_ids).each do |
score|
score.destroy
end
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 :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs