Rails has lots of built in folders and functionality magic built in, but it’s not limited to that. Like any framework, you can build on it and add extra code to meet your needs. A common way to do this with Rails is adding extra classes to better break specific functionality into different modules.

These need to be grouped into different folders in the app/ folder, and the naming structure is important. The class name and the file name must be the same, only with the class name in camel case and the file name in snake case. For example, the FakeModelQuery class must be in the fake_model_query.rb file. They can then be used by any other class in the app/ folder.

There’s a few common examples of this:

You can also use the classes from different patterns inside each other. You may have a Service that pulls data from a Query. This Service may also be used in a Presenter. A Controller could then just create a new instance of the Presenter, and everything else would be called as needed.