What type of DB column are you using? You can try without a database and use sessions instead. Worked right for me
require 'sinatra'
require 'bcrypt'
enable :sessions
get '/user' do
session[:password_hash] = BCrypt::Password.create(params[:password])
return 'success'
end
get '/session' do
result = BCrypt::Password.new(session[:password_hash]) == params[:password]
return "Result: #{result}"
end
Then in the browser
http:
# => success
http:
# => Result: true
http:
# => Result: false
If this works, try entering the database again,
require 'sinatra'
require 'bcrypt'
get '/pg-user' do
user = User.new(password_hash: BCrypt::Password.create(params[:password]))
user.save!
return 'success'
end
get '/pg-session' do
user = User.last
result = BCrypt::Password.new(user.password_hash) == params[:password]
return "Result: #{result}"
end