Skip to content

Instantly share code, notes, and snippets.

@jbritten
Created March 14, 2014 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbritten/9548243 to your computer and use it in GitHub Desktop.
Save jbritten/9548243 to your computer and use it in GitHub Desktop.
attr_accessible :invitation_code
attr_accessor :invitation_code
validate :validate_invitation_code, on: :create
def validate_invitation_code
if self.invitation_code == Digest::SHA1.hexdigest('YOUR-SECRET-DECODER-KEY' + self.email)
true
else
errors.add(:invitation_code, "is invalid")
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment