Rails 7 adds query scheduling in the background thread pool

Asynchronous querying reduces the query time significantly as opposed to running multiple queries serially. This may not be a big issue in small applications that handle a small amount of data, however, as the database grows in size the response time for these queries also grows.

Handling SQLite with Capistrano

SQLite is very useful for rapid prototyping. It’s commonly used locally but it can also be used on remote servers. If you’re using Capistrano to manage server deployments then you’ll need to handle SQLite’s database file.

Rails 5 -> 6 Upgrade: Active Storage config in Production

Whilst upgrading a Rails 5 app to Rails 6 (the Rails 7 upgrade is soon to follow) we discovered an issue when running the app in production mode:

Rails 5 -> 6 Upgrade: Fixing render file occurrences

We recently upgraded a Rails 5 app to Rails 6 (the Rails 7 upgrade is soon to follow) and discovered render file no longer works with erb files. The app was using render file to display a custom 401 error page, with dynamic content:

Updating Omniauth from version 1 to 2

We recently updated a Rails app from Omniauth 1 to 2. We did some research and used the Omniauth upgrade wiki. It looked complicated but in the end, there were only two changes required.

Upgrading Ruby, Bundler and Installing Rails 7

We’ve been working on upgrading a project to Rails 7. The app hadn’t been updated in a while, and it was running Ruby 2.6 and bundler 1.17. In order to do the Rails upgrade we had to do three things: Update Ruby, update Bundler & update Rails.

Rails 7.0 adds functionality to Assert a Single Record

Rails 7.0 has introduced two methods sole and find_sole_by that are used to query the database for a unique record based on the provided constraints. This is very useful, especially when we want to fetch just a single row, or we want to assert that multiple records don’t exist based on the conditions that have been provided.

Rails 7.0 adds encryption to Active Record

Adding an additional security layer in an application that handles sensitive data is definitely a necessity. Rails 7.0 introduces at-work encryption for sensitive attributes which protects against the exposure of personal information in the event a malicious party gains access to the database and is in a position to get a snapshot of it, as well as that of the application logs. The addition of encrypted attributes in ActiveRecord models is an extraction from HEY.

Ruby 3.1 introduces a new debugger

Ruby 3.1 ships with an entirely new rewritten debugger. Prior to this change, Ruby bundles lib/debug.rb that unfortunately was not maintained well. debug.gem is an entirely new replacement with great features that developers are sure to enjoy.

Ruby 3.1 experiments with YJIT

JIT (Just-In-Time) compiler was first introduced as an experimental feature in Ruby 2.6 with the intention of improving the performance of Ruby programs. Being experimental, memory-intensive workloads such as Rails application could not benefit from it at the moment of it’s introduction, despite achieving 1.7x faster performance as compared to Ruby 2.5.

Rails 7.0 makes Sprockets an optional dependency

Sprockets is a crucial Ruby library that is used to serve and compile web assets. However, in Rails 7.0 the library becomes an optional dependency unless the application needs to use Sprockets. In such situations, the sprockets-rails gem will have to be added to the Gemfile.

Rails 7.0 and merging ActiveRecord conditions

Rails 7.0 introduces a change that ensures conditions merged on the same column are not maintained, however, only the latter condition is retained.

Ruby 3.1 Introduces Fine-grained error location backtrace

Backtrace is very important when exceptions are raised. The sequential representation enables programmers to trace the exact location in their code where these exceptions are raised.

Rails 7 adds indefinite job retries

Rails 7 introduces a counter-fail measure in the ActiveJob framework. This is an indefinite job retries feature that would solve the different reasons why queued jobs would fail. Some of these reasons could be logical errors in the code, failure in the database, network issues, and queue malfunctions.

Running and Restarting a Rails Puma Webserver in Production

Let’s dive into how to run a Rails Puma webserver process and how to restart it.

Rails 7.0 replaces byebug with ruby/debug

Debugging information can help you understand what’s going on in your application. After Rails 5 and before Rails 7, the byebug gem was responsible for tracking the execution flow. It has been providing a way to view a complete backtrace of the code while working on the application. Rails 7 introduces debug as its default debugger.

Rails 7: PreviewError now raised in ActiveStorage

When ActiveStorage handles media uploads, the Poppler gem takes care of preview generation to be used all across the application. In previous versions of Rails, a failure in creating a preview would capture a 0-byte IO stream and send that to ActiveStorage. For instance, if a user uploaded a media file and the preview failed to generate, a 0-byte preview would still be stored and rendered, causing unexpected errors in the application.

Subscribing, Sending and Receiving ActionCable messages with vanilla JavaScript

ActionCable is an awesome feature of Rails that allows for sending real-time messages. If your frontend is part of your Rails app, much of the plumbing is handled for you. However, sometimes you need to use ActionCable, outside of Rails. In this blog post I’ll show you how to subscribe to a channel, print out messages and publish messages, all with vanilla JavaScript. Although I’m using JS, the principles apply to any language that supports websockets.

Ensure location is safe before redirecting in Rails 7.0

When you access a Rails controller from another page, the originating URL is sent to the server as the referrer. In previous versions of Rails, the redirect_back query parameter with allow_other_host set as true could allow a vulnerability for an attacker to override this parameter and force the user to a malicious page.

ActiveRecord #load_async speeds up queries in Rails 7.0

The load_async method allows you to speed up queries by loading threads in an asynchronous way. It helps reduce the response time dramatically, especially for large databases. This method handles loading records, before they are referenced in the view, making the foreground thread do the work before it is sent to the background.

Reasons Why Most SaaS Startups Fail

Quite a large number of companies are opting to get into Software-as-a-Service due to its viability as a choice of business. However, like any other business opportunity, there are a number of challenges that come with this pursuit. Most SaaS startups are bound to fail despite the ever-increasing number of businesses sprouting in the market.

Proof of Concept in Software Development

It’s invigorating to come up with a new piece of software. Team members are inspired to build something new that addresses an issue after brainstorming possibilities and envisioning potential. Ideation is thrilling, but if you don’t put your idea through its paces, you might not get the thing you want.

Interactive Prototyping - How to Prepare Clickable Application Prototypes

Some of the most successful applications rely heavily on interactive elements to maintain user engagement. For example, the social media sector has discovered how to tap into a variety of psychological features that motivate consumers to continue using their apps. These days, product design is much more than just static images. Creating interactive prototypes is now easier and more helpful than ever before when developing digital products.

Why SaaS Product Reviews Matter + How to Boost Yours

Your leads are skeptical – maybe more so than they’ve ever been. As a result, your sales and marketing strategies aren’t enough anymore. To turn new leads into customers, you need to show them real-life results and get unbiased sources to vouch for you.

7 Step Guide to Content Marketing for SaaS [Updated April 2021]

According to a 2020 study by Demand Gen Report, 67% of buyers are reading more content than ever before making purchases. In fact, 77% noted that they tend to read more than 3 pieces of content before even talking to a salesperson.