Backend to the Future I — Rails

Corey Lynch
8 min readNov 24, 2020

--

Ruby Rails logo

Frameworks are made of a series of components, including programs, compilers, libraries, toolsets, and APIs. Creating a framework is generally to facilitate the standard and efficient creation of a certain kind of software application.

My objective here is to breakdown a backend framework into its pieces to explain their purposes at a high level (Each component is likely to be worthy of its own blog post). It is my goal that by the end of this article, you will both be able to read through release notes and accurately gauge the relevance of the changes to your projects on your own, and to have the ability to add or remove the pieces you don’t need, for your current project, off the bat, and with no consequence.

The framework I will be taking apart for this post is Ruby on Rails (v5.2.4.4):

Action CableCan seamlessly integrate Websockets into your app and is used for real-time features such as a chat feature.

Default template for Action Cable

Action MailboxRoutes incoming emails to controller-like mailboxes for processing in Rails. The inbound emails are turned into InboundEmail records using Active Record. Storage of the original email on cloud storage is handled via Active Storage. The inbound emails are routed asynchronously using Active Job.

Action Mailerallows you to send emails from your application using mailer classes and views.

Default Action Mailer directory
Default template for application_mailer.rb

Action Packis a framework that provides the view and controller layers of Rails. It consists of two modules:

  • Action Dispatch — responsible for routing, handling POST, PATCH, PUT parameters, cookies, and sessions.
Example of routes.rb
  • Action Controller — used to create filters and actions to handle requests.
Example controller ( Lines 5 and 7 are giving me OCD 😬)

Action Textbrings rich text content and editing to Rails using the Trix editor.

Action Viewlooks up and renders your views. Provides view helpers that assist with HTML forms and such. Template formats include ERB and XML Builder.

Active Joba framework for declaring jobs. Jobs can be made to be anything from regularly scheduled clean-ups to billing charges to mailings.

Active Modelis a library containing various modules used in developing classes that need some features present on Active Record.

Active Recordlibrary responsible for models, model association, and the naming convention used when associating those models.

Active Storagefor uploading and referencing files in cloud services and can attach those files to Active Records.

Active Supportlibrary of useful utility classes and library extensions.

Railties — Rails core.

.rubocop.yml Configuration file for Rubocop gem. You can go here to enable or disable linting rules for Rubocop. You will need to create this file.

Gemfile — gems installed from “https://Rubygems.org by default and the default git_source (where the GitHub dependencies are pulled from) is https://github.com/{repo}.git.

Gemfile sources

Gemfile/

Gemfile contents
  • rakea gem for automating building processes and the execution of programs and libraries (Ruby Make.. Rake). Mostly used for utility (rake — tasks for more info).
Rake help
  • capybaraused to perform tests on your web application. It can be configured to work with other tests.
  • selenium-webdriverused by capybara to use Selenium automated web app tests.
  • rack-cachemiddleware that enables HTTP caching in rack-based applications.
  • sass-railsallows for Rails integration of the Sass preprocessor.
  • turbolinksenables navigation to another page without a full page reload.
  • webpackerprimarily used for Javascript in Rails.
  • bcryptused for hashing passwords.
Source: https://www.rubydoc.info/github/codahale/bcrypt-ruby/BCrypt/Password
Source: https://github.com/corymb/quicksorter Tutorial: https://www.sitepoint.com/the-ins-and-outs-of-debugging-ruby-with-byebug/

For the categories chosen here, I used https://github.com/rails/rails as a list. The idea was to provide the highest level description of each so one could briefly glance at the list and find the piece they need to fit their Ruby puzzle.

Having said that, some of the nuances are lost in these descriptions and so it may seem, by simply reading through the list, that there are multiple items that seem to achieve the same goal. In this case, I can guarantee that one of those similar items will be a superior option to the other for your use case and you should look further into both to find this superior option.

To that end, each item is linked to either their rubygems.org page, their Github repository, or the docs for that item. Whichever I thought most immediately conveyed the purpose of the item.

Lastly, I don’t have a background in computer science, so if I thought that even the explanation of something was convoluted I included additional resources to clarify. It was enlightening, for instance, to learn what an HTTP cache was but I had to look that one up.

If you see that any of my descriptions are misleading or incorrect, please let me know in the comments or message me. I would appreciate that very much as I like to learn at least one new thing each day and in this instance, you will be my teacher. I would also be happy to try to clarify any questions.

Cheers,

Corey Lynch

--

--

Corey Lynch
Corey Lynch

Written by Corey Lynch

Frontend Software Developer and Security Technician with experience in Ruby, Rails, JavaScript, and React. Flatiron Software Engineering Alumni.

No responses yet