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

Convert Figma design to code

Learn how to use the create-component package to instantly convert Figma designs into static UI components for React, Next.js, Vue, Angular, and more—styled with Tailwind CSS. This guide covers setup, design rules, conversion from design to code, and best practices for rapid, consistent UI development.

Read more

Keycloak with Google Login

This guide explains how to configure Google as an identity provider in Keycloak and allow users to log in only with Google..

Read more

Ready to Build Something Amazing?

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