Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- model -->
- require 'bcrypt'
- class User < ActiveRecord::Base
- # users.hash in the database is a :string
- include BCrypt
- def password
- @password = Password.new("$2a$10$KOk/R./LG.WSHgHkzxWJJOASTLoxQLgr7kDKUjqEonVfUt1DPZ34G")
- end
- def password=(new_password)
- @password = Password.create(new_password)
- self.hash = @password
- end
- end
- <!-- user creation -->
- def create
- @user = User.new(params[:user])
- @user.password = params[:password]
- if @user.save
- flash[:notice] = 'User was successfully created.'
- redirect_to :action => 'list'
- else
- render :action => 'new'
- end
- end
Add Comment
Please, Sign In to add comment