Way back in January, I wrote a blog post called “Rails has two default stacks”. In it, I discussed how people like to customize the defaults that Ruby on Rails gives you. Your company might prefer Postgres/HAML/RSpec, for example, over the default MySQL/ERB/MiniTest.
There’s an under-used feature of Rails that allows you to automate the creation of your own stack: templates. Check it:
$ rails --help
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /opt/rubies/ruby-2.0.0-p195/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
Application template? Yep. There’s very little documentation on this feature, unfortunately. There is a work in progress Rails Guide that gives some answers, but it’s not done yet.
Anyway, the TL;DR is this: you can write a little script to help initialize a Rails app just the way you want to. And Rails startup template is exactly that.
Here’s some of the things it gives you out of the box:
- Adds
analytics-ruby
,simple_form
,uuidtools
,rspec
,guard-rspec
, andbourbon
gems, as well as a few more. - Creates a new git repository, and optionally a new one on GitHub
- Sets up foreman for easy environment variable and background service config.
- Removes
include_tree .
from yourapplication.css
, since the author prefers to require things manually.
There are some other features, as well.
Check it out on GitHub and vote it up on Hacker News.
The post A startup template for Ruby on Rails 4 applications appeared first on The Changelog.