class User include Mongoid::Document include Mongoid::Paperclip # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, :lockable and :timeoutable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable ## Database authenticatable field :email, :type => String, :null => false field :encrypted_password, :type => String, :null => false ## Recoverable field :reset_password_token, :type => String field :reset_password_sent_at, :type => Time ## Rememberable field :remember_created_at, :type => Time ## Trackable field :sign_in_count, :type => Integer field :current_sign_in_at, :type => Time field :last_sign_in_at, :type => Time field :current_sign_in_ip, :type => String field :last_sign_in_ip, :type => String ## Encryptable # field :password_salt, :type => String ## Confirmable # field :confirmation_token, :type => String # field :confirmed_at, :type => Time # field :confirmation_sent_at, :type => Time # field :unconfirmed_email, :type => String # Only if using reconfirmable ## Lockable # field :failed_attempts, :type => Integer # Only if lock strategy is :failed_attempts # field :unlock_token, :type => String # Only if unlock strategy is :email or :both # field :locked_at, :type => Time # Token authenticatable # field :authentication_token, :type => String ## Invitable # field :invitation_token, :type => String include Mongoid::Timestamps attr_accessible :email, :password, :password_confirmation, :remember_me, :roles, :avatar # Add Paperclip support for avatars has_mongoid_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" } field :roles, :type => Array def attr_accessible_role :custom_role end attr_accessor :delete_avatar before_validation { self.avatar = nil if self.delete_avatar == '1' } end