Forum: Ruby on Rails Rails 3.2 initializers load order causes failures when config.cache_clases == true

Ca94b06e32f746968f0aec970a702a0c?d=identicon&s=25 Jason Waldrip (Guest)
on 2013-04-22 22:36
(Received via mailing list)
Hey all, we are in the midst of upgrading our app from rails 3.0.20 to
rails 3.2.13. As part of this upgrade we are experiencing an issue in
test suite in which when cache classes is turned on our models are
before our initializers. One of our initializers sets up some constants
that one of our models uses at load time. Has anyone experienced
that seems similar to this and if you could you point me the right
direction to finding a solution.

example of what is happening:
ApiServer::Application.configure do

  # Settings specified here will take precedence over those in

  # The test environment is used exclusively to run your application's
  # test suite.  You never need to work with it otherwise.  Remember
  # your test database is "scratch space" for the test suite and is
  # and recreated between test runs.  Don't rely on the data there!
  config.cache_classes = true

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local = true
  config.action_controller.perform_caching             = false
  config.consider_all_requests_local                   = true

  # Set host for using url helpers in mailers
  config.action_mailer.default_url_options = { :host => "localhost:3000"

  # Disable request forgery protection in test environment
  config.action_controller.allow_forgery_protection    = false

  config.active_support.deprecation = :log

  # Tell Action Mailer not to deliver emails to the real world.
  # The :test delivery method accumulates sent emails in the
  # ActionMailer::Base.deliveries array.
  config.action_mailer.delivery_method = :test

  # Use SQL instead of Active Record's schema dumper when creating the
  # This is necessary if your schema can't be completely dumped by the
schema dumper,
  # like if you have constraints or database-specific column types
  # config.active_record.schema_format = :sql

  config.supports_ssl = false
  config.force_ssl = false


config = YAML.load(Rails.root.join 'config', 'adapters.yml')[Rails.env]
config do |k, v|
  const_set "ADAPTER_#{k}", v

class BaseAdapter < ActiveResource::Base
   self.path = ADAPTER_PATH
   # ...

$ rails c test
`const_missing_from_s3_library': uninitialized constant
BaseAdapter::ADAPTER_PATH (NameError)
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.