I have a query like so:
@users = User.where(:something => 'met')
This returns back @users with 1+ items
What I want to do is loop through the @user object to see if a condition is met, if the condition is met I want to delete the item from the object. I’ve been trying the following but it does not appear to work though does not error.
@users.each_with_index do |u, index|
@users.delete(index) if u.id == 12
end
Suggestions on a better way to make this work?
Thank you
Do you want to delete it from the database or just from the list?
In the former case, do
In the latter, do
or, if the condition is some method on user returning “true”/”false”-ish values,