Boosting Performance and Readability: ActiveSupport::ArrayInquirer vs. includes

ActiveSupport::ArrayInquirer is a handy utility class that allows you to easily work with arrays. It makes it easy to check whether an array includes a certain value without having to write complex code.


Rails routes table search

The Rails router handles incoming HTTP requests and maps them to the appropriate controller/action. Developers can define routes by adding them to routes.rb.


Ruby on Rails Log Levels: Examples and Best Practices

Logging is important in any software development project because it helps to understand how the application is behaving and identify issues when they occur. The errors of an application cannot all be treated in the same way, as they have different levels of importance. Depending on where the error occurs in your application, it can be fatal to a process or just a warning.


Rails default Dockerfile

Docker has become an industry standard. It allows developers to create, deploy, and run applications inside containers. In Rails 7.1, Dockerfiles are included by default. This makes it easier than ever to deploy Rails applications using Docker.


Showing All Headers in Action Mailer Previews

ActionMailer previews can now display all email headers. This allows developers to check all headers, when testing locally.


Using Signed Global IDs with Polymorphic Select Fields in Rails Forms

Polymorphic associations allow a single association to reference multiple models. In a polymorphic association, the association name is used to store the name of the associated model, and the _id and _type attributes are used to store the ID and type of the associated record. However, polymorphic associations can be challenging to work with when it comes to using select fields, especially when there are multiple types of associated models.


Using Date Ranges in Rails Queries

When working with dates in Rails, it’s common to want to find records that fall within a certain range of dates. For example, you might want to find all orders placed between two dates, or all events scheduled for a certain week.


Turbo Streams Duplicate Element When Appending/Prepending

In January, 2021 a bug was reported in Turbo that caused duplicate DOM elements. In this post we’ll explain the bug and how it was fixed.


ActiveRecord regroup method

ActiveRecord’s regroup method is a shorthand for using unscope to remove existing groups.


Rails counter available in collection partials

Rails makes a counter variable available within partials that are rendered with a collection. This variable follows the name of the collection. A @users collection has a counter called user_counter. The counter works like the index on an each loop. It counts the number of times a partial has been rendered. Let’s look at an example.



Exploring the syntax_suggest feature in Ruby 3.2

Ruby 3.2 introduces the new feature syntax_suggest, formerly known as the gem dead_end, now integrated into Ruby. Catch and fix syntax errors are now more robust helping you to find the position of errors such as missing extra parentheses, commas, superfluous ends, errors such as missing or extra curly braces related to string interpolation, and semicolons.


Deploying Rails with Render

Heroku recieved some negative press for the removal of it’s free tier. Render is a cheaper alternative that boasts many benefits over Heroku. We believe Heroku is still the quickest way to spin up a Rails app but Render is close behind and less than half the price.


How to use Enumerator::Product in Ruby 3.2

Ruby 3.2 brings a convenient new addition that enables combining elements from various arrays or enumerable objects with ease. Enumerator::Product, one of the most convenient new methods, can be especially useful when working with large data sets or when generating combinations for testing purposes.


Writing to DynamoDB via Rails models

ActiveRecord is a core part of Rails, an ORM layer that sits on top of relational databases like Postgres or MySQL. However, it doesn’t natively support DynamoDB. Recently, we worked on a project to migrate part of a Rails app to Lambda functions. We began the migration by adding logic for writing to DynamoDB. Here’s how we did it.


Scaling Ruby on Rails Applications: Techniques and Tools for Optimizing Performance - Part 5 (Monitoring and Logging)

As your Ruby on Rails application grows, it becomes important to monitor its performance and log its activities. This helps you identify and fix issues, and also gives you insights into how your application is being used. In this article, we will discuss how to implement monitoring and logging in Ruby on Rails, with code examples.


How to Use the flat_map Method in Ruby

As a Ruby developer, you have probably used the map method to transform arrays and other collections of data. But have you ever needed to transform an array and flatten the result in one go? This is where the flat_map method comes in.


Using transform_values to Transform Hash Values in Ruby

In Ruby 2.4, a new method called transform_values was introduced to help transform hash values using a block. This method can be particularly useful when you need to modify the values in a hash without changing the keys.


Scaling Ruby on Rails Applications: Techniques and Tools for Optimizing Performance - Part 4 (Horizontal Scaling)

Horizontal scaling is the process of adding more servers to handle increased traffic and user activity in your Ruby on Rails application. With horizontal scaling, you can handle more requests by distributing the load across multiple servers, rather than relying on a single server to handle all the traffic. In this article, we will discuss how to implement horizontal scaling in Ruby on Rails, with a code example.


Using compact_blank to Filter Form Parameters in Rails

In Rails 6.1, a new method called compact_blank was introduced to help filter out nil and blank elements from an array. This method can be particularly useful when working with form parameters, where some fields may be left blank or undefined.


Scaling Ruby on Rails Applications: Techniques and Tools for Optimizing Performance - Part 3 (Load Balancing)

Load balancing is an important technique for scaling Ruby on Rails applications to handle high traffic loads. In this article, we will discuss load balancing and some techniques for implementing it in Ruby on Rails, along with code examples.


Scaling Ruby on Rails Applications: Techniques and Tools for Optimizing Performance - Part 2 (Database Optimization)

Database optimization is an important aspect of building high-performance Ruby on Rails applications. In this article, we will discuss some techniques for optimizing database performance in Ruby on Rails, along with code examples.


Scaling Ruby on Rails Applications: Techniques and Tools for Optimizing Performance - Part 1 (Caching)

Caching is a technique that can improve the performance of your Ruby on Rails application by storing frequently accessed data in memory or on disk. In this article, we will explore how to use caching in Ruby on Rails, and we will provide some code examples to illustrate the different types of caching available.


Building webhook endpoints with Rails

Building a Rails controller is simple and well documented. Follow the ‘Rails way’ and your life is easy. However, webhook endpoints require a different approach. In this post you’ll learn how to build maintainable and secure webhook endpoints.


Best practices for testing Ruby on Rails applications: Unit testing, integration testing, and more

Ruby on Rails is a popular web application framework that is widely used to develop complex web applications quickly and efficiently. One of the essential parts of developing a robust Ruby on Rails application is testing. Testing is crucial to ensure the application is working correctly and doesn’t have any bugs or errors that could lead to problems for users. In this article, we’ll discuss the best practices for testing Ruby on Rails applications, including unit testing, integration testing, and more.