Namespacing: why `uninitialized constant` error may occour in `development` but not in `test` environment

Updated . Posted . Visible to the public.

Example:

  class Book::Page
  end
  
  class MyBook < Book
    def new_page
      Page.new # has to be `Book::Page` in development to make it work 
    end
  end

Method new_page may throw an error when it was called during browser interaction in development but doesn't make the test fail.

The reason

Development autoloading isn't smart enough to find the referenced class
At other environments (test, staging, production) autoloading is disabled, that all classes are already loaded when browser interaction takes place what makes rails able to find the class even without the namespace.

Last edit
Deleted user #6
Keywords
exception
License
Source code in this card is licensed under the MIT License.
Posted to makandra dev (2014-02-19 09:47)