Systems | Development | Analytics | API | Testing

Rails

5 Tips to Design Ruby on Rails Transactions the Right Way

Data integrity problems are among the most common database issues Rails developers face. Besides allowing for proper validation, correctly designed transaction blocks ensure that your data isn't partially created or updated. However, transactions can also harm your application — or even take down your whole database — when not properly designed. This article offers a set of good practices for working with transactions.

The Perils of Parallel Testing in Ruby on Rails

Have you ever heard someone complain about their tests being too fast? Me neither. Fast tests mean fast feedback. Whether you run them locally or in a continuous integration pipeline, the earlier your tests finish, the earlier you can react to failures and improve your code. Besides the productivity gains, it is well known that slow tests make developers grumpy. Nobody likes their developers grumpy. With all that said, creating a lightning-fast test suite isn't always as easy as you'd hope.

Import Maps Under the Hood in Rails 7

Import maps is the new feature in Rails 7 that allows us to say goodbye to Node.js and tools like Webpack. There's no need for bundling anymore. With this new mechanism, you can still manage your JavaScript libraries with a specific version. Instead of one big file, though, your application serves many small JavaScript files. It’s essential you know how import maps work to benefit from the newest version of Rails (but don’t worry, you can still use tools like Webpack instead).

An Introduction to the ViewComponent Gem

Modern web UIs are complex. Traditional layout/template/partial techniques are not always the best fit. ViewComponent seeks to provide a better way. It's a framework for creating reusable, testable & encapsulated view components that integrate seamlessly with Rails. In this article, Abiodun Olowode shows us how to use ViewComponent to make our Rails views more manageable.

Delayed Job vs. Sidekiq: Which Is Better?

Most applications need background jobs for mailers, regular clean-ups, or any other time-consuming operation that doesn't require a user to be present. Several gems support job queues and background processing in the Rails world — Delayed Job and Sidekiq being the two most popular ones. In this post, we will take a detailed look at Delayed Job and Sidekiq, including how they fare against each other. Let's go!

Test and Optimize Your Ruby on Rails Database Performance

In this article, you will learn how to test database performance in Rails and solve some of the most common database performance issues. When you develop a Rails application, ActiveRecord is the default tool that manages your database. ActiveRecord provides an easy and fast interface to query and insert data using commands like.where, .save, .create, and.update. Rails does the work of converting these commands to SQL queries, which is a good thing, but sometimes can cause performance issues.

How to Use the Delegate Method in Rails

In most modern programming, there are objects that get involved with every aspect of an application. They are on a very high level in the hierarchy and need to interact with almost all other objects directly to ensure the proper functioning of the app. More often than not, these are objects involved in the overlaps of business logic: a User, Booking, or Account.