I grab a list of results from the database. then I ran an if statement to delete some of the results, however I don't want to delete the objects from the database, just from the list of results I pulled.
so whats the alternative method to .delete (Array.delete(object) removes from database?)
def self.search(search)
if search
results = where('title LIKE ?', "%#{search}%")
results.each do |event|
if (((event.edate + event.minduration.minute) - Time.now)/60).round.to_i > 0.to_i #if the event is over? remove it from the list.
results.delete(event)
end
end
results
else
Event.all
end
end
Or perhaps it would be best to just limit the search results to begin with, but I don't know how to combine these two conditions into one line:
results = where('title LIKE ?', "%#{search}%")
((event.edate - Time.now)/60).round.to_i > 0.to_i
Can someone help me with this problem