Code Monkey home page Code Monkey logo

roda-sequel-stack's Introduction

roda-sequel-stack

This is an application skeleton for an app using Roda as the web framework, and Sequel as the database library. It’s set up so you can clone this repository and base your application on it:

git clone https://github.com/jeremyevans/roda-sequel-stack.git my_app
cd my_app
rake "setup[MyApp]"

Database Setup

By default roda-sequel-stack assumes a PostgreSQL database, with an application specific PostgreSQL database account. You can create this via:

createuser -U postgres my_app
createdb -U postgres -O my_app my_app_production
createdb -U postgres -O my_app my_app_test
createdb -U postgres -O my_app my_app_development

Using an application specific, regular database user account (not a database superuser account), is recommended for security reasons.

Next Steps

First, you’ll want to edit the default migration file (migrate/001_tables.rb) to define the database schema for your application. After modifying the migration file, and optionally adding additional migration files, you can run the migrations:

rake dev_up  # Migrate the development database up
rake test_up # Migrate the test database up
rake prod_up # Migrate the production database up

After editing the default migration file, you’ll probably want to rename and edit the example model file (models/model1.rb), as well as add other model files as appropriate. After the models have been set up, you can get an irb shell with your models loaded:

rake dev_irb  # IRB shell with models connected to the development database
rake test_irb # IRB shell with models connected to the test database
rake prod_irb # IRB shell with models connected to the production database

After editing the model files, you’ll probably want to edit the application file (app.rb). You’ll also want to rename and edit the example routing subtree (routes/prefix1.rb). After that, you’ll probably want to edit the layout (views/layout.erb) and index page (views/index.erb), as well as add any other views.

After making those changes, you can start your application using rackup or similar program.

Main Libraries Used

roda

web framework

sequel

database library

tilt

template library

erubi

ERB template implementation

sassc

SCSS to CSS compiler

rack-unreloader

development code reloader

minitest

testing framework

minitest-hooks

around/around(:all) hooks for minitest

minitest-global_expectations

minitest expectation methods for all objects

capybara

web application testing helpers

Optional Libraries Used

sequel_pg

optimization for using Sequel with pg

sequel-annotate

Provides annotations for models

refrigerator

freezes ruby environment in production and when testing (not enabled by default, modify config.ru to enable)

simplecov

Test line/branch coverage

Roda Plugins Used

default_headers

Add security related headers for older browers

content_security_policy

Add Content-Security-Policy header

route_csrf

Add CSRF protection

flash

Support flash messages (available in next request)

assets

Allow use of SCSS for styling, automatically converting to CSS

render

Allow use of ERB templates, with HTML escaping by default

public

Serve files in public directory

hash_branch_view_subdir

Split routing tree by top-level branch, with a separate view subdirectory per route branch

common_logger

Log received requests

not_found

Show nice 404 error page

exception_page

Show detailed debugging page for internal errors in development

error_handler

Show appropriate error page for internal errors

sessions

Use encrypted cookie sessions

Sequel Plugins Used

auto_validations

Automatically validate model objects based on database schema

prepared_statements

Use prepared statements for inserts/updates for model objects

subclasses

Freeze model classes in production and during testing

Environment Variables Used

#{APP}_DATABASE_URL

database connection URL to give to Sequel, default is to create one based on the application’s name and RACK_ENV.

#{APP}_SESSION_SECRET

cookie session secret, must be >=64 bytes

RACK_ENV

environment to use (production, development, or test), defaults to development.

Specs

To run the specs for the application after running rake setup, run rake. To run specs for the stack itself (to test if the stack itself is functioning as expected), run rake before running rake setup. The specs for the stack itself depend on the gems in Gemfile, as well as the rackup and webrick gems (puma will also be used if installed).

Author

Jeremy Evans <[email protected]>

roda-sequel-stack's People

Contributors

jeremyevans avatar elbouillon avatar adam12 avatar dbreunig avatar ababich avatar scottt2 avatar vais avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.