I’m trying to find the most recent time a contact was marked “done”. Contacts belong to a User. I have this method in my User Model, but I know it can probably be improved.
def last_contact_done_days
date_array = self.contacts.find(:all, :select => "date_done").to_a
most_recent = date_array.max
last_done_days_ago = Date.today - most_recent[:date_done]
return last_done_days_ago
end
Thanks!
You could use this method:
OR (shorter version with try method):