What is this file config.ru, and what is it for?

config.ru is a Rack configuration file (ru stands for “rackup”). Rack provides a minimal interface between web servers that support Ruby and Ruby frameworks. It’s like a Ruby implementation of a CGI which offers a standard protocol for web servers to execute programs. Rack’s run command here means for requests to the server, make Sinatra::Application … Read more

How to make Sinatra work over HTTPS/SSL?

this seems to do it for me: require ‘sinatra/base’ require ‘webrick’ require ‘webrick/https’ require ‘openssl’ CERT_PATH = ‘/opt/myCA/server/’ webrick_options = { :Port => 8443, :Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG), :DocumentRoot => “/ruby/htdocs”, :SSLEnable => true, :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, :SSLCertificate => OpenSSL::X509::Certificate.new( File.open(File.join(CERT_PATH, “my-server.crt”)).read), :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open(File.join(CERT_PATH, “my-server.key”)).read), :SSLCertName => [ [ “CN”,WEBrick::Utils::getservername ] ] } … Read more

What is a very simple authentication scheme for Sinatra/Rack

Here is a very simple authentication scheme for Sinatra. I’ll explain how it works below. class App < Sinatra::Base set :sessions => true register do def auth (type) condition do redirect “/login” unless send(“is_#{type}?”) end end end helpers do def is_user? @user != nil end end before do @user = User.get(session[:user_id]) end get “https://stackoverflow.com/” do … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)