OSDN Git Service
(root)
/
wvm
/
gitlab.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6d92aa6
)
Implementing automatic password creation.
author
Jakub Troszok
<troszok@gmail.com>
Sun, 24 Jun 2012 20:26:13 +0000
(22:26 +0200)
committer
Jakub Troszok
<troszok@gmail.com>
Sun, 24 Jun 2012 20:26:13 +0000
(22:26 +0200)
app/models/user.rb
patch
|
blob
|
history
diff --git
a/app/models/user.rb
b/app/models/user.rb
index
69d5ec7
..
484853b
100644
(file)
--- a/
app/models/user.rb
+++ b/
app/models/user.rb
@@
-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