Missing Import Errors in Rails
Rails uses Zeitwerk for autoloading, which means you rarely need explicit require statements. When you see NameError: uninitialized constant X, something is misconfigured.
Zeitwerk Naming Conventions
Zeitwerk expects class names to match file paths:
# app/models/user.rb → User
# app/services/payment_processor.rb → PaymentProcessor
# app/services/stripe/charge_service.rb → Stripe::ChargeService
# BAD — file name doesn't match class
# app/services/stripeChargeService.rb → expects StripeChargeService
# but you defined Stripe::ChargeServiceCheck Autoload Paths
# config/application.rb
config.autoload_paths += %W[#{config.root}/lib]
config.eager_load_paths += %W[#{config.root}/lib]Common Errors
Constant not found in development but works in production (or vice versa):
# Check for naming issues
bin/rails zeitwerk:checkGem class not available:
# Gemfile — make sure it's not in the wrong group
gem 'sidekiq' # Available everywhere
# NOT:
group :development do
gem 'sidekiq' # Won't be available in production!
endExplicit Require
For code outside autoload paths:
# For non-autoloaded files
require 'csv'
require 'net/http'
require_relative '../lib/custom_parser'Concerns and Modules
# app/models/concerns/searchable.rb
module Searchable
extend ActiveSupport::Concern
# ...
end
# app/models/product.rb
class Product < ApplicationRecord
include Searchable # Autoloaded from concerns/
endBugsly captures NameError and LoadError in Rails with the constant name and backtrace, showing exactly where the missing reference was triggered.
Try Bugsly Free
AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.
Get Started FreeRelated Articles
How to Fix Encoding Error in Rust
Learn how to fix the Encoding Error in Rust. Step-by-step guide with code examples.
Read moreWhy Your Error Tracking Tool Doesn't Explain Errors (And What to Do About It)
Most error tracking tools show you stack traces but leave you guessing about root causes. Learn why AI-powered analysis changes everything.
Read moreFix Missing Import in Swift
Resolve 'No such module' and missing import errors in Swift projects, covering SPM dependencies, framework linking, and module maps.
Read moreHow to Fix Query Error in Go
Learn how to diagnose and fix the query error in Go. Includes code examples and prevention tips.
Read more