Boxcar is the Rails application template used at Smashing Boxes according to our best practices.
This template is compatible with:
- Rails 5.0.0
- Rails 4.2.7.1
The template currently assumes:
- PostgreSQL
and that the application will be deployed using:
- Taperole
- Unicorn
NOTE: Taperole is not yet compatible with Rails 5.
To create a new Rails app with this template, do the following:
git clone https://github.com/smashingboxes/boxcar.git
To use Rails 5, do the following:
rails new [app_name] -m boxcar/template.rb -B
To use Rails 4, do the following:
rails _4.2.7.1_ new [app_name] -m boxcar/template.rb -B
If you run into an issue with Rails 4.2.7.1, run gem install rails -v 4.2.7.1
to ensure you have access to this version of Rails.
Note that the -B
is optional and equivalent to --skip-bundle
. Since there is a bundle install command inside the template, the final bundle when creating a new Rails app is unnecessary.
Note that this command will be updated when the template is compatible with Rails 5.
When using this template, you will be asked one or more questions to determine what type of Rails app to generate. There are 3 types of apps you can select:
- API Only
- Answer 'y' to the question "Is this an API app? (y/n)".
- Answer 'n' to the question "Does this API app have an admin interface? (y/n)"
- API with Admin Interface
- Answer 'y' to the question "Is this an API app? (y/n)".
- Answer 'y' to the question "Does this API app have an admin interface? (y/n)"
- Interactive
- Answer 'n' to the question "Is this an API app? (y/n)".
The template will generate a Rails app using rails new
, and then will customize the app according to the template. Depending on the type of template you are generating, the template will modify the following:
- API Only
- Modify the Gemfile
- Remove files from the app directory, including helpers, views, and assets > javascripts and stylesheets
- Modify the application_controller.rb file for an API
- Option to install the gem 'devise_token_auth'
- Option to install the gem 'smashing_docs'
- API with Admin Interface
- Modify the Gemfile
- Remove Turbolinks
- Option to install the gem 'devise_token_auth'
- Option to install the gems 'cucumber-rails' and 'capybara'
- Option to install the gem 'smashing_docs'
- Interactive
- Modify the Gemfile
- Remove Turbolinks
- Option to install the gem 'devise'
- Option to install the gems 'cucumber-rails' and 'capybara'
Once these app-type dependent modifications are complete, the template will modify the following:
- Create database.yml configured for postgresql
- Create database.example.yml and secrets.example.yml
- Create .rubocop.yml file for local linting
- Create .travis.yml file correctly configured
- Append .gitignore with secret_token.rb, secrets.yml and database.yml
- Bundle install and installation of gem configs:
- rspec
- factory_girl_rails
- database_cleaner
- shoulda_matchers
- codeclimate-test-reporter
- taperole
- Installation of optional gem configs:
- smashing_docs
- devise
- devise_token_auth
- cucumber-rails
- capybara
- Cleanup of auto-generated files that fail local linting
- Remove test directory
- Generate README.md
- Create development and test databases
- Initialize git
Boxcar contains application gems including:
- Devise for authentication
- Devise Token Auth for token-based authentication
- Postgres for access to the Postgres database
- Unicorn as the app server
- Taperole for deployment
NOTE: For now, the template will only install and set up taperole if using Rails 4. When taperole is compatible with Rails 5, we will add this functionality back.
And development gems including:
- Letter Opener to view emails in browser
- Better Errors to access an IRB console on exception pages
- Spring for fast Rails actions via pre-loading
- Web Console for better debugging via in-browser IRB consoles
And testing gems including:
- Awesome Print to pretty print Ruby objects
- Binding Pry to stop execution and get a debugger console
- Capybara to simulate how a user interacts with the app
- Code Climate Test Reporter to integrate Code Climate and Travis
- Cucumber Rails for automated feature tests
- Database Cleaner for cleaning the database
- Factory Girl for test data
- RSpec Rails for unit testing
- Rubocop for linting
- Shoulda Matchers for common RSpec matchers
- Smashing Docs for API documentation