Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #controller
- @user = User.new(params[:user]).makepassword
- #model
- def makepassword
- chars = ("a".."z").to_a ("A".."Z").to_a ("1".."9").to_a
- self.password=''
- 1.upto(6) { |i| self.password << chars[rand(chars.size-1)] }
- self.hashed_password=Digest::MD5.hexdigest(self.password)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement