I have a model that does an 'include' of a module defined in the lib directory. The module, in turn, uses 'require' to load a class defined in the system load path. Running the application in development mode, the initial request goes through successfully. However, the second time around, I get a NameError resulting from "uninitialized constant", with the constant in question being a class that is defined in the script that is 'require'd in the lib module. In brief it looks like this:
app/model/revision.rb: class Revision include MyLib::Mod end
lib/my_lib/mod.rb: module MyLib module Mod require 'extension/clazz' end end
On the second request, the class defined in extension/clazz cannot be found, resulting in the NameError. However, if I add "require 'extension/clazz'" into the model, just before the 'include', it works such that every request is successful. Likewise, if I run the applicaiton in production mode, it works every time.
Is this expected behavior, or is this a bug in Rails?
Thanks
n