Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Layered Design for Ruby on Rails Applications

You're reading from  Layered Design for Ruby on Rails Applications

Product type Book
Published in Aug 2023
Publisher Packt
ISBN-13 9781801813785
Pages 298 pages
Edition 1st Edition
Languages
Author (1):
Vladimir Dementyev Vladimir Dementyev
Profile icon Vladimir Dementyev

Table of Contents (20) Chapters

Preface 1. Part 1: Exploring Rails and Its Abstractions
2. Chapter 1: Rails as a Web Application Framework 3. Chapter 2: Active Models and Records 4. Chapter 3: More Adapters, Less Implementations 5. Chapter 4: Rails Anti-Patterns? 6. Chapter 5: When Rails Abstractions Are Not Enough 7. Part 2: Extracting Layers from Models
8. Chapter 6: Data Layer Abstractions 9. Chapter 7: Handling User Input outside of Models 10. Chapter 8: Pulling Out the Representation Layer 11. Part 3: Essential Layers for Rails Applications
12. Chapter 9: Authorization Models and Layers 13. Chapter 10: Crafting the Notifications Layer 14. Chapter 11: Better Abstractions for HTML Views 15. Chapter 12: Configuration as a First-Class Application Citizen 16. Chapter 13: Cross-Layers and Off-Layers 17. Index
18. Gems and Patterns 19. Other Books You May Enjoy

Data Layer Abstractions

This chapter opens Part 2 of the book, in which we will talk about the particular patterns in extracting abstraction layers. As we discussed in Part 1, growing Rails applications feel too cramped within model-controller-view boundaries; introducing new abstractions allows your code to breathe freely. We start with the Rails model layer and its core component—Active Record.

In Chapter 2, Active Models and Records, we learned that Active Record models are by design responsible for representing domain objects and communicating with the persistence engine. In this chapter, we will discuss the techniques for reducing the responsibility of Active Record by introducing new abstraction layers. First, we will discuss how to keep the query-building functionality organized via query objects. Then, we try to leverage Data Mapper ideas and use repositories for Active Record models.

We will cover the following topics:

  • Using query objects to extract (complex...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}