Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 3 KB

README.md

File metadata and controls

52 lines (35 loc) · 3 KB

Sinatra Boilerplate

See this code running1

The problem

You want a simple Ruby web app, quick, right? Rails too complicated for your needs? You still want to use a database, and your website to look presentable?

Me too! So I created this boilerplate, with just enough but not too much added in. Different people have different definitions of that; this is mine.

The solution

This includes the following tools:

Features

  • Responsive navbar (source) including a search box, drop-down menu and will shrink on smaller screens
  • Set the HTML title attribute on a per-page basis
  • Passes all default rubocop cops
  • Deployable to Heroku as-is
  • Multiple controllers & helpers demonstrated
  • Valid, standard-compliant HTML

Setup instructions

  • To get the database running locally, it's recommended by Heroku, & myself, that you install postgres locally. Remember to change the contents of database.yml in accordance with your dev setup. Other database engines are available, like sqlite.
  • Run bundle install
  • Run rackup and your app should be running at http://localhost:9292

What next?

  • Develop your database by creating migrations (bundle exec rake db:create_migration NAME=create_table_name), these will appear inside db/migrate. Fill the file in as appropriate and run (rake db:migrate)
  • Read the Heroku docs for more information about deploying such apps to Heroku
  • Add more tools if you'd like - such as SASS or a different template engine if you don't like erb.
  • Code awesome stuff!

Other sources

I've linked to many of the sources above but I'd also like to mention...

1: This is hosted on Heroku's free tier. This means that if no-one has visited the site in the last 30 minutes, it shuts down, and thus will take a few seconds to load up again. Therefore it's important to remember that this is not indicative of the typical response time of this lightweight app.