Customizing Rails in Other Ways

Learn to customize Rails in other ways as well.

We'll cover the following

Overview

Customizing the edges of Rails, as we did above with CSS, HTML templates, and tests tends to be more straightforward and provide more options for us. Customizing Rails’ internals is more difficult. If you want, we can remove Active Record entirely and use libraries like Sequel or ROM, but we’d be giving up a lot. Active Record is tightly coupled with many parts of Rails.

Tight coupling is usually viewed as a problem, but it’s this coupling that allows us to be so productive using Rails. The more we change our Rails app into a loosely coupled assembly of unrelated libraries, the more work you have to do getting the pieces to talk to each other. Finding the right balance is up to you, your team, and your project.

The Rails ecosystem is also filled with plugins and enhancements to address common needs that aren’t quite common enough to be added to Rails itself. For example, Kaminari provides pagination for when we need to let a user browse hundreds or thousands of records. Ransack and Searchkick provide advanced ways of searching our database with Active Record. CarrierWave makes uploading files to our Rails app much more straightforward than hand-rolling it ourselves.

If we want to analyze and improve the code inside the Rails app, RuboCop can check for consistent style, while Brakeman can check for common security vulnerabilities.

These extras are just the tip of the iceberg. The community of extensions and plugins for Rails is yet another benefit of building your next web application with Rails.

Get hands-on with 1200+ tech skills courses.