I have a very simple task at hand. If the last time a record was updated has been longer than 15 minutes, display a button. Otherwise, don't display the button.
The field is a datetime.
My view code:
<% if @object.display_button? -%>
my button
<% end -%>
My display button method on that object:
def display_button?
return false if last_updated.nil?
if Time.now - last_updated > 15.minutes
true
else
false
end
end
I also have this unit tested, which are passing, but when it comes to the implementation, it doesn't seem to work.
Is my logic correct or would there be a better way of accomplishing this?