I'm Jason, a web application developer in East Tennessee.

Generating a New Rails Project

The great thing about working with a framework like Ruby on Rails is how you can pick and choose the components that make up your application. Developers often have preferences concerning solutions or tools they use in their projects. They have the choice of testing tools such as Rspec or Cucumber, testing factory libraries such as FactoryBot or Fabrication, authentication solutions such as Devise or AuthLogic, and authorization solutions such as CanCan or Pundit.

It can feel heavy having to reconfigure a freshly generated Rails application to use these different components, because you spend most of your time configuring the new application rather than jumping into actually building the functionality.

Application Templates

Thankfully Rails supports Application Templates that make configuring a new application a breeze.

It’s possible for you to configure your own custom template with your primary preferences all in one file. You could maintain your own template in a Github Gist using this option.

See my example template.

App Template Command

Even better than this is that you can choose to apply certain configurations to your application ala carte by using the ‘app:template’ rails command. This command allows you to run template fragments from publicly hosted template scripts. You can find many scripts for various solutions on Rails Bytes.

My Recipe

I prefer to use tools provided by the JavaScript / ECMAScript eco-system facilitated by NodeJS packages for my front-end, using Webpack. Ruby on Rails applications get support for this from Webpacker. I like ReactJS, but I prefer VueJS for my own personal projects.

Because I use Webpack as my asset pipeline for the front-end application and assets, I don’t need the Rails asset-pipeline or page rendering helpers. This causes me to prefer using an API-only configuration with Ruby on Rails.

To create a new application, I use the following command to generate an API Application, using Webpacker to with a VueJS front-end.

rails new my_application --api --webpack=vue --database=sqlite3 --skip-test --skip-turbolinks --skip-sprockets

After I’m done generating the application, I use the following application templates to setup my app.

Here are some optional recommendations that depend on the type of application you are developing:

  • Friendly ID - “Swiss Army bulldozer” of slugging and permalink plugins for Ruby on Rails. See friendly_id
  • Ahoy - Track visits and events in Ruby, JavaScript, and native apps. Data is stored in your database by default so you can easily combine it with other data. See Ahoy
  • PgHero - Performance Dashboard for PostgreSQL. See PgHero
  • Pundit - Authorization system. See Pundit
  • Vue with InertiaJS - Library supporting conventional interface between front-end tools (React, Vue.js, and Svelte) and back-end (Laravel and Rails). See InertiaJs
  • SendGrid - Configures Ruby support for SendGrid email service API
  • GraphQL - Add a GraphQL API to your Rails app
  • DelayedJob - Background Job processing. See DelayedJob
  • Sidekiq - Background Job processing. See Sidekiq
comments powered by Disqus