GithubHelp home page GithubHelp logo

simple-sinatra-mvc's Introduction

Dependency Status

Simple Sinatra MVC Template

What's included

  • Sprockets
  • HAML
  • SASS
  • PostgreSQL gem (pg)
  • CoffeeScript (coffee-script)
  • Pony
  • Rubocop
  • A lot more
$ git clone --depth 1 git://github.com/katgironpe/simple-sinatra-mvc.git myapp
$ rm -r myapp/.git && rm myapp/README.md

Use bundler to install gems

$ bundle install

Start the app

$ rackup

or

$ shotgun config.ru

Unit and acceptance tests

Ruby 1.9 includes minitest so it just makes test to use minitest instead of any other framework. It works and it is simple. Use:

$ rake test

For acceptance tests, some example is also provided. Use:

cucumber

Or use the rake task (lib/tasks/test.rake):

rake features

Configuration

$ cp config/database.yml.example config/database.yml

Update database.yml

By default, we use PostgreSQL.

To install PostgreSQL on a Mac, you might need homebrew.

$ brew install postgresql

Creating a database should be as simple as:

$ createdb database_name

You may have to update config.ru and files on config directory as needed.

Rake Tasks

$ rake -T

rake assets:clean # Clean assets rake assets:precompile # Precompile assets rake db:create_migration # create an ActiveRecord migration rake db:migrate # migrate the database (use version with VERSION=n) rake db:rollback # roll back the migration (use steps with STEP=n) rake db:schema:dump # dump schema into file rake db:schema:load # load schema into database rake features # Run Cucumber features

To create a database for a specific environment, do:

$ rake db:create RACK_ENV=production

The default environment is "development"

To create a migration file called "create_pages", do:

$ rake db:create_migration NAME=create_pages

To do migration:

$ rake db:migrate RACK_ENV=production

To rollback:

$ rake db:rollback RACK_ENV=production

The default is development so this should just work:

$ rake db:migrate

To start the application, use shotgun:

$ bundle exec shotgun config.ru

Asset Pipeline

Yes, it is very easy to get asset pipeline working for Sinatra. By default, we have the following supported directories:

  • app/assets/javascripts
  • app/assets/stylesheets
  • app/assets/images

You may append more paths as needed by adding directory name to the assets_paths array.

set :assets_paths, %w{fonts images javascripts stylesheets}

To precompile assets, simply use the rake task for it either on your deployment file or locally:

rake assets:precompile RACK_ENV=production

You have to use the asset helpers provided by sprocket-helpers gem.

Caching Assets

We use memcached to speed up loading of assets and storing them whether they're compressed or not. It is highly recommended to enable this by default in production.

To install memcached:

brew install memcached

Performance Monitoring

Newrelic RPM

I found a need to add this all the time. You will just need to download the newrelic.yml file.

simple-sinatra-mvc's People

Contributors

kathgironpe avatar

Watchers

Shanicky Chen 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.