I am getting an uninitialized constant ActiveRecord::AssociationNotFoundError (NameError) on my production environment only, development/staging works fine. When I comment out the lines from the code that is running in production, in a docker container by the way, the code runs fine.
I have this exception handler module inside controller/concerns
This module is included by Application Controller
the line:
rescue_from ActiveRecord::AssociationNotFoundError do |e|
json_response({ status: '422', details: [ { message: e.message } ] }, :unprocessable_entity)
end
config/environments/production
Rails.application.configure do
config.cache_classes = true
config.hosts << "www.example.com"
config.hosts << "limpar-api"
config.cache_store = :redis_cache_store, { url: ENV.fetch("REDIS_URL_CACHING", "redis://localhost:6379/0") }
config.eager_load = true
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.active_storage.service = :local
config.log_level = :debug
config.log_tags = [ :request_id ]
config.action_mailer.perform_caching = false
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
config.active_record.dump_schema_after_migration = false
end
config/environments/staging
Rails.application.configure do
config.active_record.migration_error = false
config.active_record.verbose_query_logs = true
end
Any idea why?