Engines on Rails

By Debanjan Sengupta

Elevator Pitch

Introduced in the way back at 2014, Ruby on Rails web development framework is ruling the industry for almost a decade and a half. The time has come to learn and explore the rails engines to supercharge the monolithic monster applications built during the span, to make those more modular and faster.



[Why Rails Engines?]{.underline}

  • With the growing demands from the market, with the strive for the excellence and with the focus on the results, the organizations who have adopted Rails at least some 5 years back, the traditional MVC is falling short to keep those applications tiered and structured enough. Also, with the introduction of many MVC JS libraries like Backbone.js, React.js etc. more layers have been introduced in these applications. Ruby and Rails has provided some of the features by themselves like concerns, helpers, modules and services to keep codes subjective to avoid fat files, but the overall load and execution time has always been an issue.

  • Being a less explored area of the framework, for various reasons like time-bound development to accommodate the refactoring, lack of expertise and also the limitations in the previous versions, we need to explore this gray area to enlighten some of the great aspects of mountable engines into applications. This is not something very new and resources are already available across networks, the article will more focus to encourage developers to use engines to segregate different modules inside a monolithic application.

  • Separate repositories and versions for components across the application, that can be documented, developed, tested and released with their standalone SDLC. Anything goes wrong and all it takes to revert to the previous engine and not go through the painful process to select and revert commits from the main application which is always risky and error-prone.

[Topics Covered:]{.underline}

  • What is a Rails Engine and how it works?

  • Generating a Rails Engine and explore the file structures it.

  • Nest an application component inside the engine.

  • Mount the engine with the main application.

  • Additional setup for an engine.

  • More refinements.

  • Live Demonstration.



Technical requirements: (Preparation is done using the following)

  • ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

  • Rails 4.2.10

  • MySQL Server version: 5.6.27 Homebrew