Motivation ⇡
Self-introduction into Roda, Sequel ecosystem and Zeitwerk autoloading.
Setup ⇡
- Install dependencies:
bundle install- Configure the
.envfile
touch .env
# Generate a secret key:
ruby -r 'securerandom' -e 'puts "SECRET_KEY=#{SecureRandom.hex(32)}"' > .env
# Add database name:
cat "DATABASE_NAME=YOUR_DB_NAME" > .env- Prepare the database (sqlite3):
bundle exec rake db:create
bundle exec rake db:migrate- Run Puma application server at
http://localhost:9292with a Rake default task:
rake
# OR to run explicitly:
rake startApplication structure & architecture ⇡
The application is built with:
- Roda routing toolkit for routing
- Sequel for database connection, migration and ORM
- sequel_tools to use Rake tasts for DB operations
- Zeitwerk to autoload/reload application during development
- dry-configurable for
ApplicationSettingsclass to store application settings - tilt & erubi for the view layer
- Entrypoint:
config.ru requiresconfig/bootrequiresconfig/application_loaderandconfig/application_settingsconfig/application_loadersets up the zeitwerk gem, which autoloads the wholeappdirectory- Rack runs the
Routerfromapp/router.rb(basically the application itself, with routes and actions)
Models are in app/models directory.
Views are in app/views directory. Partials are supported as well.