Reader small image

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

Product typeBook
Published inAug 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781801813785
Edition1st Edition
Languages
Right arrow
Author (1)
Vladimir Dementyev
Vladimir Dementyev
author image
Vladimir Dementyev

Vladimir Dementyev has been working on web applications for more than 10 years and launched his first Ruby on Rails project back in 2014. Since then, he has been working on a dozen of Rails web applications, used by hundreds of millions of customers, monolithic or component-based, following the Rails way or trying to swim against the current. He has been an active member of Rails open-source community since 2015, becoming a regular Rails contributor, a RailsConf speaker, and the author of dozens of gems, including AnyCable, TestProf, and Action Policy to name a few. For his work on the Ruby Next project, the author got the Fukuoka Ruby Award for outstanding performance in 2021. Currently, he's leading the backend developers' team at Evil Martians, helping dozens of web projects around the world build better software.
Read more about Vladimir Dementyev

Right arrow

Filter objects or user-driven query building

If we continue our web development simplification that we started at the beginning of this chapter, we can say that besides forms and links, we build data tables and lists. For example, a list of repositories on GitHub or an inbox in a web email client. What do these interfaces have in common? They all have filtering, sorting, and search controls available to users. Whenever we display a large amount of homogeneous data to a user, we want to make their life easier and allow narrowing down the scope.

Such user-driven querying requires processing input parameters and applying transformations to the base dataset based on the values provided. Let’s see how we can implement this in a Ruby on Rails application.

Filtering in controllers

Just like before, we start with a pure Rails way of solving this problem. For parameter-based filtering, that means putting transformation logic right into the controller class.

Let’s consider...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Layered Design for Ruby on Rails Applications
Published in: Aug 2023Publisher: PacktISBN-13: 9781801813785

Author (1)

author image
Vladimir Dementyev

Vladimir Dementyev has been working on web applications for more than 10 years and launched his first Ruby on Rails project back in 2014. Since then, he has been working on a dozen of Rails web applications, used by hundreds of millions of customers, monolithic or component-based, following the Rails way or trying to swim against the current. He has been an active member of Rails open-source community since 2015, becoming a regular Rails contributor, a RailsConf speaker, and the author of dozens of gems, including AnyCable, TestProf, and Action Policy to name a few. For his work on the Ruby Next project, the author got the Fukuoka Ruby Award for outstanding performance in 2021. Currently, he's leading the backend developers' team at Evil Martians, helping dozens of web projects around the world build better software.
Read more about Vladimir Dementyev