Implementing automatic password creation.

This commit is contained in:
Jakub Troszok 2012-06-24 22:26:13 +02:00
parent 6d92aa6d12
commit 9132d309ad

View file

@ -53,6 +53,14 @@ class User < ActiveRecord::Base
scope :blocked, where(:blocked => true)
scope :active, where(:blocked => false)
before_validation :generate_password, :on1 => :create
def generate_password
if self.password.blank? && self.password_confirmation.blank?
self.password = self.password_confirmation = Devise.friendly_token.first(8)
end
end
def self.filter filter_name
case filter_name
when "admins"; self.admins