Guest User

Untitled

a guest
Mar 7th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <!-- model -->
  2. require 'bcrypt'
  3.  
  4. class User < ActiveRecord::Base
  5. # users.hash in the database is a :string
  6. include BCrypt
  7.  
  8. def password
  9. @password = Password.new("$2a$10$KOk/R./LG.WSHgHkzxWJJOASTLoxQLgr7kDKUjqEonVfUt1DPZ34G")
  10. end
  11.  
  12. def password=(new_password)
  13. @password = Password.create(new_password)
  14. self.hash = @password
  15. end
  16.  
  17. end
  18.  
  19.  
  20. <!-- user creation -->
  21. def create
  22. @user = User.new(params[:user])
  23. @user.password = params[:password]
  24. if @user.save
  25. flash[:notice] = 'User was successfully created.'
  26. redirect_to :action => 'list'
  27. else
  28. render :action => 'new'
  29. end
  30. end
Add Comment
Please, Sign In to add comment