[Rails] 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 :-)
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home