Giter Site home page Giter Site logo

skygroundmedia / boilerplate-sinatra Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 21 KB

Boilerplate Sinatra App

License: Apache License 2.0

Ruby 60.13% HTML 30.55% CoffeeScript 2.37% CSS 6.95%
boilerplate-sinatra heroku procfile foreman sinatra sinatra-applications ruby-application

boilerplate-sinatra's Introduction

Boilerplate Sinatra

Boilerplate Sinatra app that includes:

  • Heroku-Ready
  • User Registration
  • Sendmail using GMail and Sendgrid
  • Warden Authentication

Step 1

Download this app

Install this codebase

Step 2

Set-up your dev environment

Make sure you're using Ruby 2.2.5. If not, review this article on how to upgrade Ruby on Mac OS X using rbenv

 ruby -v

Update gem –the package manager we're going to use.

 sudo gem update

Update all the app packages found in Gemfile.

 sudo gem install bundler 

Step 3

Install app packages

Install all the app specific packages

 bundle install --without production

Step 4

Start local webserver

Start your web server (using Procfile + Foreman )

 gem install foreman
 foreman start

Step 5

Build your app

Step 6

Configure Heroku

Install Heroku

 sudo gem install heroku

Log in to Heroku

 heroku login

If you need a local SQL database, you'll need to pick PostGres

Configure Heroku Toolbelt

Step 8

Publishing from Git to Heroku

Verify the remote git

  git remote -v 

Verfify you have an app in Heroku

  heroku apps

Link your git to Heroku

  heroku git:remote -a [name of app on heroku]

Step 9

Bundle and Lock down your Gemfile

  bundle install --without production

Publish your git code to Heroku and Github

  git push heroku master

Databasese

Managing a local DB through IRB

First register your database by finding and promoting it

 irb
 require './app'
 DataMapper.auto_migrate!

Managing a production DB through Heroku's Console

First register your database by finding and promoting it

  heroku pg
  heroku pg:promote [HEROKU_POSTGRESQL_NAME_OF_DATABASE]
  heroku run console
  require './app'
  DataMapper.auto_migrate!

Installing SQLite

Use Homebrew to install SQLite

  ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
  brew install sqlite
  gem install sqlite

Process

  1. Gemfile is used to store all the libraries and dependencies you'll need to launch and deploy your app.
  2. Procfile is the process file you used to kickstart your app.
  3. Foreman is the toolkit you use to automatically start-up your server
  4. SQLite is what you'll use for a local SQl database
  5. Postgresql is the SQL database you'll use for production
  6. config.ru is the configuration file that connect Procfile to your initial app.rb file.

Adding a new property to the Database

Add the property within the class

 property :likes, Integer, :default => 0

Use IRB to migrate the database

 bash$ irb

Use DataMapper to update the tables

 DataMapper.auto_upgrade!

Test out your work

 bash$ irb
 require './app' 
 bash$ song = Song.first
 bash$ song.likes

Double check your DB on Heroku

Run Console

 heroku run console

Upgrade DB

 require './main'
 DataMapper.auto_upgrade!

Resources

Authentication

Boilerplate Code


Errors

foreman start

Web server errors Find out if any servers are running 'headless'

 ps aux | grep ruby

Quit any 'headless' running servers

 kill -9 xxxxxx

Check Heroku logs

  heroku logs

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.