All the gems used by default
In order to send emails
No gem are used here, because it’s already inside Rails by default.
However, it is important to take time to understand how Action Mailer work, because emailing is an important part of many Rails application.
Authentication alone requires email to work properly.
If you are not comfortable with Action Mailer, here is an article we wrote, it’s also how we installed Action Mailer :
Old assets (CSS, JS…) pipeline
This is the old assets pipeline for Rails. It is not used, but keeped for backward compability reasons.
gem "pg", "~> 1.1"
Postgre is the most used production-ready, relational database in the Ruby-on-Rails world, so we just kept in simple here.
The web server
gem "puma", "~> 5.0"
Puma is the default web server for Rails.
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
We don’t know much about this default gem, but without it, Rails doesn’t work on the Windows platform.
Modern frontend assets management
ViteJS is a complete for the Ruby-on-Rails frontend assets management. The frontend assets management is very unstable since Rails 5.1, so our idea is to use something already stable in the industry, and just keep Sprockets as backward compatibility.
In order to understand how we build it, here is an article on the blog : https://www.bootrails.com/blog/vitejs-rails-a-wonderful-combination/
gem "rodauth-rails", "~> 1.0"
Rodauth is an elegant authentication gem for Rails. Yes, we are aware of Devise, Clearance, Sorcery, etc. But Rodauth is far better for at least two reasons :
- very minimalistic installation
- Ruby based, so not invasive inside the Rails layers
- very easy to extend if needed
- excellent supports from the creators
Here is how we installed it : https://www.bootrails.com/blog/rails-authentication-with-rodauth-an-elegant-gem/
Stubbing email locally
gem 'letter_opener', group: :development
Letter Opener allows the developer to view any sent email in the browser (e-mail are not actually sent), automagically.
Background jobs are almost mandatory in a Rails app, just for authentication, you need email confirmation, password recovery, etc, that are all handle via emailing.
And it is strongly advised to deliver emails with the
.deliver_later method. That can only be properly handled, in production, by a specific job runner like Sidekiq or DelayedJobs.
Here is how we installed it : https://www.bootrails.com/blog/rails-sidekiq-tutorial/
In-memory, key-value database
Redis is a key-value database. It has numerous use-cases in a Rails app. So far it is only needed by Sidekiq, but in a near future, Redis will serve other features.
Awesome print allows better debugging. Write
ap @my_variable anywhere, and once reached, it will be beautifully printed in the console.
Monitoring Rails DB
gem "rails_db", ">= 2.3.1"
It can be very handy to debug the app directly in the browser.
Read environment variables locally
gem 'dotenv-rails', groups: [:development, :test]
Environment variables are variables that should not be hardcoded in the repository, because they may change at any moment. Think about secret passwords or URL.
This gem allows the developer to use them in development and test mode.
# inside .env, at the root of the Rails project MY_KEY=MY_VALUE [email protected]
You write them inside a “.env” file, and you can then access them via ENV[‘MY_KEY’]
Rails is unable to read Markdown, unless you use an appropriate gem. Once the is loaded, you can access it via
gem 'cypress-rails', groups: [:development, :test]
System testing is possible by default with Rails, but very tedious to install and unstable once launched.
Instead, Cypress is a well-known standard of the industry. Mature, stable, and very easy to use.
Here is the article we wrote about it : https://www.bootrails.com/blog/rails-cypress-testing/
Stubbing external requests while testing
gem 'webmock', groups: [:test]
We feel Webmock mandatory for one reason : avoid the test suite to reach any real URL.
You could be banned from real website, and you could slow down your test suite easily.
One line ensure that no real URL will ever be reached :
Code excerpt should be pretty clear 🙂
gem 'simplecov', require: false, group: :test
Customers are not allowed to access the admin dashboard for example. Visitors are not allowed to access their profile.
action_policy is an advanced version of the well-known
gem 'heroku-deflater', :group => :production
Gzip will compress JS and CSS files. On heroku, this is possible thanks to the ‘heroku-deflater’ gem, however, if you don’t use Heroku, you can simply remove this gem from the Gemfile.