Book Image

Layered Design for Ruby on Rails Applications

By : Vladimir Dementyev
4.7 (3)
Book Image

Layered Design for Ruby on Rails Applications

4.7 (3)
By: Vladimir Dementyev

Overview of this book

Ruby on Rails is an open-source framework for building web applications from scratch while focusing on productivity, leveraging the power of the convention-over-configuration principle, and the well-defined model-view-controller pattern, assisting the developers in building useful features. However, this initial simplicity often leads to uncontrollable complexity turning the well-structured codebase into a hardly maintainable mess. This book aims to help you keep the code maintainable while working on a Rails application. You’ll start by exploring the framework capabilities and principles, allowing you to reap the full potential of Rails. Then, you’ll tackle many common design problems by discovering useful patterns and abstraction layers. By implementing abstraction and dividing the application into manageable modules, you’ll be able to concentrate on specific parts of the app development without getting overwhelmed by the entire codebase. This strategy also encourages code reuse, simplifying the process of adding new features and enhancing the application's capabilities. Additionally, you’ll explore further steps in scaling Rails codebase, such as service extractions. By the end of this book, you’ll be a code design specialist with a deep understanding of the Rails framework principles.
Table of Contents (20 chapters)
1
Part 1: Exploring Rails and Its Abstractions
7
Part 2: Extracting Layers from Models
11
Part 3: Essential Layers for Rails Applications
17
Index
18
Gems and Patterns

What this book covers

Chapter 1, Rails as a Web Application Framework, provides a high-level overview of the framework and its core components specific to it being a tool for building web applciations

Chapter 2, Active Models and Records, focuses on the Rails model layer and how to better leverage its building blocks, such as Active Record and Active Model, to extract responsibilities and prevent God objects.

Chapter 3, More Adapters, Less Implementations, focuses on the design patterns used by Active Job and Active Storage.

Chapter 4, Rails Anti-Patterns?, discusses Rails’ controversial features, such as callbacks, concerns, and globals.

Chapter 5, When Rails Abstractions Are Not Enough, focuses on the Service Object phenomenon in Rails and introduces layered architecture principles.

Chapter 6, Data Layer Abstractions, focuses on extracting data manipulation logic (querying and writing) from models.

Chapter 7, Handling User Input outside of Models, provides an overview of abstraction layers to move user input handling out of models, such as form and filter objects.

Chapter 8, Pulling Out the Representation Layer, focuses on abstractions used to prepare model objects for displaying in the UI, for example, presenters and serializers.

Chapter 9, Authorization Models and Layers, focuses on authorization aspects and the corresponding abstractions.

Chapter 10, Crafting the Notifications Layer, focuses on extracting an abstraction layer to handle logic related to user notifications (email, SMS, and so on.).

Chapter 11, Better Abstractions for HTML Views, discusses abstractions to maintain HTML templates in Rails applications.

Chapter 12, Configuration as a First-Class Application Citizen, discusses the problem of configuring web applications.

Chapter 13, Cross-Layers and Off-Layers, focuses on Rails application infrastructure aspects, such as logging and monitoring, and provides examples of abstraction-driven service extraction.