/default_rails_template

Default template for generating new Rails applications.

Primary LanguageRuby

Rails Default Template

The Infinum default template for generating new Rails applications.

Requirements

Install the latest ruby version and set it as global

If you installed rbenv through homebrew:

brew upgrade ruby-build

If you installed rbenv with git:

  cd "$(rbenv root)"/plugins/ruby-build && git pull

then run if needed:

  rbenv install #{latest_ruby}
  rbenv global #{latest_ruby}

Usage

rails new myapp --database=postgresql -T -B -m https://raw.githubusercontent.com/infinum/default_rails_template/master/template.rb

The -T flag skips minitest files.

The -B flag skips the second bundle install.

The -m flag tells the generator to run our app template.

What does this template do?

  • Updates the README.md file
  • Creates bin/setup and bin/update scripts
  • Creates a config/environments/staging.rb file
  • Updates the config/environments/development.rb file
  • Creates a Bugsnag initializer
  • Removes gems we never use: coffee-rails, jbuilder, tzinfo-data & byebug
  • Adds Bugsnag & Figaro to the Gemfile
  • Adds Pry-Rails to the Gemfile, inside of the development and test group
  • Adds Rubocop, RSpec-Rubocop & Overcommit to the Gemfile, inside of the development group
  • Adds Rspec-Rails to the Gemfile and initializes it
  • Initializes deploy script with Mina
  • Initializes spring binstubs
  • Updates the secrets.yml file to use Figaro and have defaults
  • Creates a config/application.yml file for Figaro
  • Creates a .rubocop.yml file with our defaults
  • Git inits
  • Adds more common gitignored files to .gitignore
  • Adds documentation in docs folders

Recommendations

After running the template generator, this script will install overcommit which won't let you commit your project if it has some Rubocop offenses or if your Gemfile isn't alphabetically sorted. To sort your Gemfile, use the Eefgilm gem. Install it with gem install eefgilm and run the eefgilm command to sort your Gemfile.

Filling up the documentation

Here is an example of line inside documentation:

* ACCOUNT-NAME (ACCOUNT-ID) <!-- infinum-dev (7021-9251-8610) --> <!-- DEVOPS -->

The first comment is an example of how to fill the data on the left

The second comment is who can fill this information. It can be either DEVOPS or DEVELOPER. If you as a DEVELOPER have access to a specific information, you can also fill up DEVOPS lines (for example, if you have access to AWS console, most of the information in server documenation can be filed by a developer).

Development

There are a couple of helpers you can use when developing:

ask_with_default # Presents a user with a question he can answer. Returns default if user does not enter anything
yes?             # Ask a user yes/no question. Returns true/false