Is there some sort of short hand for
@notifications = Notification.find(:all, :conditions => ['expires_at > ?', Time.now])
notif = Notification.find(:all, cookie[0].to_i)
@notifications.delete(notif[0]) if not notif.empty?
cookie is an id of a notification stored into cookies. this is in an iteration, that removes notifications that the user doesn't want to see.
thanks! =)
If this is an array of activerecord objects, you could delete from the database like this.
Notification.delete_all(:id => cookie[0].to_i)
If this is just an array, then you can use the delete if
@notifications.delete_if{|x| x == cookie[0].to_i}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With