Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Autoloading issues
# /config/application.rb
module RailsApp
class Application < Rails::Application
config.autoload_paths += Dir["#{config.root}/lib/**/"]
config.autoload_paths += Dir["#{config.root}/app/jobs/**/"]
config.autoload_paths += Dir["#{config.root}/app/workers/**/"]
config.autoload_paths += Dir["#{config.root}/app/services/**/"]
end
end
# /app/controllers/testing_controller.rb
class TestingController < ApplicationController
include Preferences
def lookup
result = TestUserValidator.validate(params)
end
end
# /app/services/preferences/test_user.rb
module Preferences
class TestUser
...
end
end
# /app/validators/preferences/test_user_validator.rb
module Preferences
class TestUserValidator
...
end
end
# Error Message
# Completed 500 Internal Server Error in 8ms
# NameError (uninitialized constant TestingController::TestUserValidator):
# app/controllers/testing_controller.rb:5:in `lookup'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.