Rails Autoload Path

by Yuva, Co-founder

Typically autoload paths configured in application.rb will be like this:

config.autoload_paths += %W(lib)

Recently we faced a problem where we were adding another root level folder app to autoload_paths, and using one of utility classes inside that folder. Everthing worked fine in development, but not in production. We started seeing strange errors while running migrations:

cannot load such file -- app/subdir1/utility_class

Inspecting $LOAD_PATH revealed that there is no absolute path for app folder. Appending autoload_path with absolute path solved this issue.

config.autoload_paths += [ Rails.root.join("app") ]

More articles

Operating Kafka in Rails with Karafka: Production Architecture, Consumers, and DLQs (Part 2)

In Part 2, we dive deep into the Sync-Out pipeline—how Rails publishes events to Kafka, how our legacy adapter writes to SQL Server 2009 using TinyTDS, and how Dead-Letter Queues (DLQs) became our lifeline during production incidents. This post covers transaction management, service objects, and operational workflows for handling failures.

Read more

Operating Kafka in Rails with Karafka: Production Architecture, Consumers, and DLQs (Part 1)

This post breaks down our production architecture for event streaming in Rails using Kafka and Karafka—from designing producers and consumer flows to handling failures with DLQs and keeping warehouse databases in sync reliably.

Read more

Ready to Build Something Amazing?

Codemancers can bring your vision to life and help you achieve your goals