Created
July 6, 2012 22:14
-
-
Save reqshark/3063053 to your computer and use it in GitHub Desktop.
mongodb user model
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 User | |
| include MongoMapper::Document | |
| safe | |
| authenticates_with_sorcery! | |
| key :name, String, :required => true | |
| key :email, String, :unique => true | |
| key :crypted_password, String | |
| key :salt, String | |
| key :reset_password_token, String, :default => nil | |
| key :reset_password_token_expires_at, Time, :default => nil | |
| key :reset_password_email_sent_at, Time, :default => nil | |
| key :remember_me_token, String, :default => nil | |
| key :remember_me_token_expires_at, Time, :default => nil | |
| key :remember_me_token, String | |
| key :last_login_at, Time, :default => nil | |
| key :last_logout_at, Time, :default => nil | |
| key :last_activity_at, Time, :default => nil | |
| validates_length_of :password, :minimum => 3, :message => "3 characters min", :if => :password | |
| validates_confirmation_of :password, :message => "should match confirmation", :if => :password | |
| many :authentications, :dependent => :destroy | |
| User.ensure_index([[:remember_me_token, 1], [:last_logout_at, -1], [:last_activity_at, -1]]) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment