Team Qameta Blog Posts

Identify unused Routes in Ruby on Rails

Reading time: 4 minutes

Custom Rake Task: Identify unused routes in Ruby on Rails

Rails routes map URLs of a Ruby on Rails application to controller actions. As a project grows, many new routes get added and older ones might become obsolete. Cleanup of unused routes is a good practice to keep the codebase clean and maintainable. This article shows how you can identify unused routes in Ruby on Rails before 7.1 and after 7.1 with built-in tooling.

Use Geocoder and MaxMind DB to Geocode IP Addresses

Reading time: 6 minutes

Explore Google IP address data

Utilizing IP addresses for communication is a fundamental aspect of many web applications employing HTTP(S) as their protocol, particularly those interconnected to the internet. However, a multitude of IP addresses are also generated through protocols such as SSH, SMTP, or IMAP. In this article, we’ll explore how to determine their origins and extract valuable data using the geocoder gem in conjunction with the MaxMind GeoLite2 Database.

Default URL Options in Ruby on Rails

Reading time: 7 minutes

Ruby on Rails default_url_options in console

Like most Ruby developers you have to set a default_url_options on a Ruby on Rails project. Depending on the use case you have to set several of them with different values.

The name of the method default_url_options is the same, but it is used in different contexts (controller, mail, or file storage, it may be confusing and can even have side effects for your project you have to figure out yourself. Depending on the value you set, they may be reused in other contexts like ActiveStorage, ActionMailer, and third-party gems like devise. I couldn’t find any official documentation for the most common cases (web, mail, file storage, test), I’ve written one.

Working with Legacy Ruby on Rails: spring.gem fork() Crash

Reading time: 4 minutes

Spring Fork Crash on Ruby on Rails

Working with legacy Ruby on Rails applications is for most developers a problem, as they have a lot of extra work to do:

First of all, many developers will hit the CPU architecture change from x86/x64 to ARM64 using Apple Macs. Even installing older Ruby versions on a newer OS (operating system) on a x86/x64 architecture is hard. It produces a lot of problems, warnings, and errors.

Analyzing SassC::SyntaxError in Ruby on Rails 7.0

Reading time: 3 minutes

SassC::SyntaxError in Ruby on Rails

I was running a up to date Ruby on Rails 7.0 project using cssbundling-rails. The project was in production for several months. After pushing the code to Continuous Integration (CI) using GitHub Actions it failed with an error:

Deploy Ruby on Rails 7.0 to Dokku micro PaaS

Reading time: 10 minutes

Dokku Website

This tutorial was tested with Dokku version 0.34.0

Deploying a Ruby on Rails application to a Dokku instance is pretty forward. There are only a few things you have to consider. In this guide, I will tell you, what might be the things and how to solve them. I was missing a complete guide with explanations aligned to the deployment of a default Ruby on Rails application.

Fixing require LoadError as an example for the matrix gem

Reading time: 3 minutes

cannot load such file matrix LoadError

Some gems like matrix or rexml were added at some point to ruby becoming so-called default gems. But they may be removed from being default in newer ruby versions, resulting in broken builds like for us with prawn:

Analyzing Geofeed Technology to improve IP networks

Reading time: 3 minutes

Geofeed example

Geofeed is a list of IP networks with basic geolocation information. It is published using CSV format through an http(s) address. Most of these addresses are shared informally between trusted parties. Some were published on sites like Reddit: Starlink has published IP Geolocation mapping.

Fix Flaky Rails System Tests caused by slow scrolling or animations

Reading time: 6 minutes

Chrome and Chromium Smooth scrolling flag

Flakiness on browser-based system tests (integration tests) in Ruby on Rails may have a lot of different reasons. One is scrolling, which may be slowed down by browser setup (smooth scrolling), JavaScript callbacks which result in some kind of events like for animations, etc.

Howto migrate from Webpacker to jsbundling-rails in Ruby on Rails

Reading time: 9 minutes

Using jsbundling-rails for JavaScript pipeline

A lot of Ruby on Rails applications created with Ruby on Rails version 5.x or 6.x or even upgraded from the previous versions are using webpacker as their primary asset pipeline. But now as webpacker has retired, it is time to move on. jsbundling-rails is or will be the most obvious step to go. Don’t try to move to importmap-rails directly, as you may encounter more problems you have to solve.

Howto migrate from Webpacker to cssbundling-rails in Ruby on Rails for CSS

Reading time: 6 minutes

Using cssbundling-rails for CSS pipeline

A lot of Ruby on Rails applications created with Ruby on Rails version 5.x or 6.x or even upgraded from the previous versions are using webpacker as their primary asset pipeline. But now as webpacker has retired, it is time to move on. cssbundling-rails is or will be the most obvious step to go.

Howto remove sprockets-rails from you Ruby on Rails project

Reading time: 3 minutes

Remove Sprockets from Ruby on Rails

Before removing sprockets-rails from dependencies of your Ruby on Rails project, check whether you are surfing images or fonts using sprockets through assets paths like:

… or any other assets except Style Sheets (CSS):

If you are using cssbundling-rails the sprockets default path for Style Sheets is used by default:

Copy Files Compressed with Tar via ssh from and to a Linux Server

Reading time: 5 minutes

Copying files from a development machine or a server to another one may take up a lot of time, resources and traffic which dependent on the task may be more or less a problem. There are common Linux/Unix tools like scp and rsync to do the job, but they may be a wrong choice dependent on the task like:

New Alternative Search Engine: neeva and neevaAI

Reading time: 2 minutes

neeva search results for qameta

Today the new neevaAI search engine launched on Product Hunt. This is the third launch on Product Hunt with all new added AI functionality.

What is neeva?

Neeva is an alternative search engine focusing on better results. They say about theirself:

To use or not to use assert_predicate with minitest in Ruby

Reading time: 3 minutes

Recently RuboCop started to blame my assert something.booked? style tests in minitest and telling me this:

Minitest/AssertPredicate: Prefer using `assert_predicate(something, :booked?)`.

I’ve looked for the corresponding Pull Request and also checked the final Rubocop Minitest Style Guide: Assert Predicate.

According to the documentation, we can read:

Target Alternative Search Engines through IndexNow

Reading time: 4 minutes

Targeting alternative Search engines by simply looking to search engines market number may look like a waste of time, but there is a lot of value we may miss. IndexNow Technology is here to help you with this target.

Why targeting alternative search engines at all?

Targeting alternative Search engines to Google may look like a waste of time because of the market reach Google has, but there are many reasons you may consider:

Define Default URL for ActiveStorage to fix Mixed Content Error

Reading time: 3 minutes

Using ActiveStorage with external services like AWS S3 for saving and surfing attachments like images is great. The setup is well explained in Active Storage Overview in Ruby on Rails Guides.

But if you start using it, you will maybe encounter some problems, which are not that easy to find or debug, as they mostly appear in production. One of the problems we encountered was a Mixed content related to ActiveStorage. This was not a big problem at first, as you get only a warning in a browser with default configuration. But after we added an iOS App, which was using WkWebViews, some random redirects to AWS S3 images stopped working. We couldn’t even see connections for these images to ActiveStorage endpoint of our Ruby on Rails Application in logs, which made it harder to debug.

Define Canonical URL in a Hugo Theme

Reading time: 2 minutes

Hugo is a Static site generator, but links to your site may contain optional parameters like ref=... which may produce duplicate content for search engines. You can use canonical URL to define, which URL should be used by Google and co.