Home

Awesome

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}

GitHub Actions

This template uses GitHub Actions for CI/CD. In order for workflows to work properly some secrets have to be set up.

For build workflow to work, the following secrets must exist (usually set up by DevOps):

For deploy workflows, you need to generate private/public SSH key pairs for each environment. Public key should be added to the server to which you're deploying. Private key should be added as a secret to GitHub and named SSH_PRIVATE_KEY_#{ENVIRONMENT}, where ENVIRONMENT is replaced with an appropriate environment name (STAGING, PRODUCTION, etc.).

Slack notifications

Build and deploy workflows can send Slack notifications upon completion of workflow runs. To enable this, add the following to the workflow:

By default, a notification will be sent if the run either succeeded or failed. If you want notifications only on successful runs, add the notify_on input to the workflow with the value success. Similarily, if you want notifications only for failed runs, the value of the notify_on input should be failure.

Frontend

If your application will have a frontend (the template will ask you that), you must have Node installed on your machine. The template creates a .node-version file with the Node version set to the version you're currently running (check by executing node -v). Therefore, ensure that you have the latest Active LTS version of Node running on your machine before using the template.

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?

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