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.

Problem with autoload and nested modules/classes

#6465

Hello!

Let I have extras/ in autoload_paths, and also I have classes:

extras/gate/flight.rb

class Gate::Flight
end

extras/gate/reciever.rb

class Gate::Reciever
  Flight #load Gate::Flight for us
  Flight #ArgumentError: Gate is not missing constant Flight! 
end

Is it normal behavior, and I should always type Gate::Flight in all nested modules/classes?
If not, I make a patch to fix this issue.

Reported by Alexander Stanko · February 24th, 2011 @ 02:00 PM

State: duplicate
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • State changed from new to duplicate
    • Importance changed from to Low

    This is a duplicate of #5383 AS dependencies resolver broken: not missing constant error - if you rewrite your class definitions so that they're not inline everything will work, e.g:

      module Gate
        class Flight; end
        class Receiver
          Flight #load 
          Flight 
        end
      end
    

    This is because Ruby searches for constants in Object first when defined as ModuleName::ClassName but inside the parent module when nested properly.

    March 5th, 2011 @ 06:39 PM