Skip to content

Instantly share code, notes, and snippets.

@lbergen
Created June 26, 2012 15:36
Show Gist options
  • Save lbergen/2996472 to your computer and use it in GitHub Desktop.
Save lbergen/2996472 to your computer and use it in GitHub Desktop.
before_save :check_for_blanks
...
def check_for_blanks
debugger
if (self.token.blank?)
self.token = ApiKey.generate_token
end
if (self.rate_limit.blank?)
self.rate_limit = 500
end
if (self.expiry_date.blank?)
self.expiry_date = 1.month.from_now
end
if (self.status.blank?)
self.status = 'active'
end
if (self.roles.blank?)
self.roles = []
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment