While switching between projects I’ve been looking for a way to make sure I can run all the services necessary without worrying about the subtle differences between codebases.

I use the following bin scripts to help.

Setup & Updating

The prepare script is a recent addition to my arsenal although it is generated in new Rails apps.

The setup script is not only useful when setting up the project for the first time, but also when updating the project. For instance after adding a new gem, a new NPM package or after creating a database migration.

For extra ease, I have started using asdf-vm to handle Ruby and Node versions for each project all that is required is a .tool-versions file

The additional asdf install line in this script makes sure I have the correct versions of Ruby and Node available. Again these work well for new and updated applications.

The setup script also includes a rails db:prepare. This is a Rails 6 addition that will handle creating a new database or updating the database. This article explains the functionality.

Server

My typical Rails project will have job queues and use webpacker. To get all of these running normally requires running rails server, sidekiq and bin/webpack-dev-server each in a separate window.

I like to combine all of these into a Procfile.dev and run them all using foreman (either added globally - gem install foreman - or in the development group of the Gemfile).

To make life even easier I wrap all of this into one script bin/dev

Formatting/Linting

  • [bin/lint][bin_lint]

This script will no doubt be marmite, I both love and hate it.

I like to use translations as much as possible throughout my applications so i18n-tasks gem is really handy for keeping the locale yml files at peace as well as checking for missing translations.

On top of that we also have standardrb --fix and npx standard --fix. standardrb and standard will make sure that your code remains nicely formatted.