Handling User Input outside of Models
In this chapter, we’ll continue discussing abstractions related to Rails models. This time, we will talk about user-driven operations and the corresponding design patterns. First, we’ll talk about modifying operations (creating or updating models) and introduce the concept of a form object, which is an object representing a user interface form in the code base. Then, we’ll discuss how to read (or filter) data based on user-provided parameters with the help of filter objects.
You will learn how to identify functionality that can be moved to form and filter objects, so you can introduce new abstraction layers and reduce the responsibility of the existing ones (especially the model layer).
We will cover the following topics:
- Form objects – closer to the UI, farther from persistence
- Filter objects or user-driven query building
This chapter aims to give you practice in extracting the presentation...