Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Constants no longer available at load in 2.1.0

#443

I have a constant PLATFORM_INTERFACE assigned in my environment.rb. This constant references a module that is included in many other models throughout my app. (It is a constant as the module varies depending on the platform the app is running on)

For example, my application controller has the line:

include PLATFORM_INTERFACE

Prior to 2.1, this worked fine. However, as of 2.1 it throws an uninitialized constant error whenever it is included in a class: for example

'uninitialized constant ApplicationController::PLATFORM_INTERFACE'

So it appears that constant that is assigned in environment.rb is not available when the application controller (as well as all other controllers and models) are loaded. There was no mention of a change in the load order for 2.1, so I am going to assume it is a bug.

Reported by Daniel Lockhart · June 18th, 2008 @ 01:03 AM

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Daniel Lockhart
    Daniel Lockhart

    So after more investigation, it turns out the problem only occurs in plugins as long as you preface the constant with :: (The :: was not necessary pre-2.1.0) The error still occurs when a plugin tries to reference the constant, whether prefixed with :: or not.

    A workaround is to use .send :include in the environment.rb.

    June 18th, 2008 @ 06:20 PM

  2. josh
    josh
    • State changed from new to invalid
    • Milestone cleared.

    Avoid initializing stuff in environment.rb. Use the initializers folder.

    June 18th, 2008 @ 06:24 PM