Web アプリ用の Sinatra の選択が気に入り、データベース アダプター用のSequelをお勧めします。テストされていない短いアプリを次に示します。
require 'sinatra'
require 'sequel'
require 'haml'
DB = Sequel.connect('sqlite://blog.db')
get '/' do
@entries = DB[:posts].filter(live:true).order(:posted_on.desc).all
haml 'home' # finds 'views/home.haml' and makes a string
end
get '/:postname' do
@post = DB[:posts][short: params[:postname]]
haml 'post'
end
ホーム.haml
- # this will be wrapped in layout.haml if you have one
%h1 My Posts
%p Welcome to my site, I hope you like it.
#posts
- @entries.each do |post|
%h2{id:post[:short]}
%a{href:post[:short]}= post[:title]
%p= post[:overview]
post.haml
%h1= @post[:title]
%p#overview= @post[:overview]
#contents= @post[:html]
Sinatra、Sequel、または Haml の完全な紹介は、Stack Overflow の範囲外です。これで始められることを願っています。