Created
August 10, 2009 19:10
-
-
Save ymendel/165357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Invitation < ActiveRecord::Base | |
# Returns encoded invitation id | |
def encoded_id | |
self.id*10011981 * 1820062 - 1981 | |
end | |
def self.decode_id(id) | |
i = ((id.to_i + 1981)/1820062)/10011981 | |
if (i*10011981 * 1820062 - 1981)==id.to_i | |
begin | |
Invitation.find(i).id | |
rescue | |
false | |
end | |
else | |
false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment