Unhidden Gems: 4 Highlights from Our Recent Ruby on Rails Sessions

Updated November 9, 2023

At Whitespectre, knowledge sharing is a core part of our DNA. We strengthen our capabilities by regularly hosting structured yet informal cross-team sessions where we share what we’ve been doing, learn from others, and debate different approaches. These sessions help build the Whitespectre “brain trust”, which makes us collectively smarter and more efficient at building software.

We recently hosted a dedicated X-Rails session where we gathered our Ruby on Rails developer community. Have a look at four gems we uncovered at this latest session:

Implementing WebSocket Connections with Rails

Over the past three years, among other Rails projects, Whitespectre has also worked on complex platforms and applications centered on hardware and software integration.

In his X-Rails talk, Ricardo Leitao shared his team’s steps to connect SpotOn’s virtual fence app and collar tracker for dogs based on Bluetooth, GPS, and cellular technologies. Velocity and reliability in the flow of data were a must since the app would have to handle the virtual fences that range from a half acre to more than 1,000 acres, while also monitoring and tracking the behavior of the dogs. The team behind the app managed to achieve this with a combination of live WebSocket connections, action cables to make it easier on the tech side, and cellular to maintain a live connection with the collar.

Using Sidekiq to Improve Performance

In another project, Rafal Jamroz’s team was tasked with processing significant amounts of data and generating extensive reports on demand.

The team recurred to Sidekiq. In his X-Rails talk, Rafał explained that this is a commonly used tool for background processing in the Ruby world. But ultimately, it was the batch-processing capabilities that made it an excellent fit for this job, mainly because of its outstanding performance.

Sidekiq Batch (requiring Sidekiq Pro, but there’s a free open-source alternative) was used to split data-heavy jobs processed in multiple threads, and callbacks were used to combine the results and then clean up. The callbacks can also be used to act on failures by sending a notification – in our case, over Slack.

The project also needed another type of worker to push order information to third-party services (also using batches). In this case, they used the ShipUp service to track shipments and notify customers when a box gets delivered or about shipping delays. This service had an API rate limit, and thus they couldn’t submit more than 120 requests per minute. In this case, the solution was to use a self-rescheduling job based on the redis_rate_limiter gem.

Keeping Up with Rails 7

Being up to date with the latest releases in the Ruby world is key for the health of all projects, and Marc Camara discussed some very useful gems that come with Rails 7, which in some cases are promoted as the new standard to be used with Rails 7 applications.

With Import Maps, instead of getting all JavaScript files and compiling them into one huge js file, you can rely on http2 to retrieve all packages in different requests. This has the benefit of being easier to cache and easier to see where something went wrong.

Propshaft is an alternative asset pipeline for Rails. In short, it’s faster and simpler than sprockets, and the app does not need lots of changes to replace one for the other.

Kredis is a gem that makes using Redis easier than ever, by reading and writing it as if it was a huge hash living in the application. It also contains helpers for ActiveModel that can come in handy in many cases.

Finally, Marc introduced Hotwire, a Turbo + Stimulus combination that only uses Ruby to make writing dynamic pages easier.

Optimizing the Workflow with a Monorepo

Konstantin Nechepurenko and Diogo Rosa explained how they turned a cumbersome workflow of a big SaaS into a seamless experience by moving from a Multirepo to a Monorepo approach.

While reviewing the SaaS, they considered various options to develop a Ruby on Rails solution that was customizable for each client but that still shared functionalities via libraries.

The approach, which consists of merging all the projects and their dependencies into one repository, means that each project’s versions of gems will stop being used, and they will all use the current version.

They explained how everything changed on the CI/CD, the folder organization, and the GIT process. However, that still wasn’t the biggest deal – a game-changer for the everyday developer’s work was a series of scripts they created to run several vital functions. You can read an in-depth take on this approach in this article.

When it comes to building web apps, Ruby on Rails is a versatile way to handle everything you need from web development to data processing and automation. As demonstrated by these examples from Whitespectre experts, the possibilities are broad and exciting. We hope these insights will inspire you to consider new ways to use Ruby on Rails as the foundation in your web projects, and help you transform your development process and end product.

Let’s Chat