Skip to content

Instantly share code, notes, and snippets.

@gkilmain
Last active December 19, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gkilmain/5960028 to your computer and use it in GitHub Desktop.
Save gkilmain/5960028 to your computer and use it in GitHub Desktop.
before_save :set_expiration_date #once its been saved update the expires_at attribute with the set_expiration_method
def expired?
if accepted! #if an offer has been accepted it cannot expire
return false
else
created_at > expires_at #if created_at is greater than expires_at return true, else return false
end
end
def set_expiration_date
self.update_attribues(:expires_at => created_at + 6.months)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment