Skip to content

FrontendMatter/bs-layout-boilerplate-rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bs-layout-boilerplate-rails

Rails application boilerplate using Bootstrap Layout.

Demo

You can see a working live demo of this boilerplate running on Heroku.

Usage

Clone the boilerplate repository

git clone https://github.com/themekit/bs-layout-boilerplate-rails.git my-project
cd my-project

Asset dependencies

npm install

Rails dependencies

This application boilerplate runs on Rails 2.3.1. We recommend installing rvm (Ruby Version Manager) and then install ruby:

rvm --force install 2.3.1
rvm --default use 2.3.1

Install Bundler and Rails:

gem install bundle
gem install rails

Install the application dependencies:

bundle install

Development server

Start rails server on http://localhost:3000:

rails s

Production mode

Precompiling assets:

RAILS_ENV=production bin/rake assets:precompile

Start rails server in production:

rails s -e production

Files of interest

The complete list of files modified or created in addition to the default Rails installation.

├── .env
├── Gemfile
├── Procfile
├── app
│   ├── assets
│   │   ├── javascripts
│   │   │   └── application.js
│   │   └── stylesheets
│   │       └── application.css.scss
│   ├── controllers
│   │   └── static_controller.rb
│   └── views
│       ├── layouts
│       │   ├── application.html.erb
│       │   └── fixed.html.erb
│       └── static
│           └── content.html.erb
├── config
│   ├── application.rb
│   ├── environments
│   │   ├── development.rb
│   │   └── production.rb
│   └── routes.rb
└── package.json

Database

For the purpose of this application boilerplate, we intentionally disabled the database connection.

Install database driver

To use the default Rails database connection, uncomment the following from the Gemfile:

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

Install the gem:

bundle install

Enable Active Record

Uncomment the following in config/application.rb:

require "active_record/railtie"

# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true

Uncomment the following in config/environments/development.rb:

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

Uncomment the following in config/environments/production.rb:

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

Running the Rails app on Heroku

First, get a free Heroku Account and download the Heroku Toolbelt. Then, login to Heroku:

heroku login

From the project root directory, create a Heroku app. Note that Heroku generates a random name for your app or you can pass parameter to specify your own app name.

heroku create

Buildpacks

Configure the Heroku app to use the official Ruby buildpack:

heroku buildpacks:set heroku/ruby

Add the Node.js buildback at the first position, to ensure npm install runs first:

heroku buildpacks:add --index 1 heroku/nodejs

Production mode

Configure the Heroku app to use the production mode:

heroku config:set RACK_ENV=production

Database

Note that sqlite3 will NOT work on Heroku. See details and alternatives on https://devcenter.heroku.com/articles/sqlite3

Local development

To run the Heroku app on http://localhost:5000, run:

heroku local

Deploy

When you created the app with heroku create, a git remote (called heroku) was also created and associated with your local git repository. To publish the application, you simply have to push to that remote:

git push heroku master

Ensure at least one instance of the application is running:

heroku ps:scale web=1

Visit http://<APP NAME>.herokuapp.com in your browser to see the Rails app running.


Get help

Get help directly from our team via our Slack channel. Request invite