I have a module called Retain. That module has pieces in
app/controller/retain, app/model/retain, and lib/retain. If I have to,
I can rename them but, for now, that is what I have.
In lib/retain I have a file called exceptions where I define my
exceptions like:
module Retain
class RetainEerror < StandardError
end
class FooError < RetainError
end
…
end
I have an explicit “require ‘retian/exception’” in one of my
controllers. The very first run through the code, it finds FooError,
etc. The next time (like if I hit refresh), it does not. FooError
becomes undefined.
This is in development mode and I have class caching turned off:
config.cache_classes = false
Is the fact that I have the Retain module scattered all over the
problem? If not, can anyone suggest what the problem might be?
This is in development mode and I have class caching turned off:
config.cache_classes = false
Is the fact that I have the Retain module scattered all over the
problem? If not, can anyone suggest what the problem might be?
Probably not the problem with scattering the file all over the place.
More likely to do with Rails’ dynamic reloading of the files on each
refresh in development mode.
What happens if you turn on class caching or run in production mode?
If this works, you might want to move the require ‘foo’ into the
application_controller as a more central require location or even
better, put it in as an initializer file in config/initializers if you
are on Rails 2.0 or in an environment.rb file if you are not.
I turned on the class caching and that solved the problem. I then
turned it back off and rearranged the require and put the require in
config/initializers and that is working too.
Thanks for your help,
pedz
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.