Skip to content

Instantly share code, notes, and snippets.

@reqshark
Created July 6, 2012 22:14
Show Gist options
  • Select an option

  • Save reqshark/3063053 to your computer and use it in GitHub Desktop.

Select an option

Save reqshark/3063053 to your computer and use it in GitHub Desktop.
mongodb user model
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