I'm trying to figure out where to put objects that aren't strictly
"model" objects (ie, not database/business objects, these are actually
objects holding information regarding the ui). I've seen a couple
answers which is to create the classes in a module file in /lib, or to
create the objects as non-ActiveRecord class files.
Both of these solutions work, of course. However, when working in the
rails development environment they aren't reloaded on the fly in
webrick/mongrel when they're modified. Restarting the server everytime
I modify one is a bit of a pain.
The one fix I have found is to just throw the class definitions in one
of the Helper files and instantiate it with the full path, with an eye
to moving it to lib when finished. It works, but it's really nasty and
I would prefer to come up with a "right" solution.
The concept would be, for instance, that I am creating a web
application that has multiple windows. Each window is an instantiation
of a Frame object, it's the Frame objects I need to know where to put.
That's it, however sometimes Rails is weird about when it'll reload and
when it won't. I still have to restart webrick/mongrel in a few cases
(which I can't remember at the moment). Anyone care to enumerate them
here?
I think I see what’s going on here. The lib/ system is very dependent on the filename <-> classname relationship. Thus, you have lib/my_lib.rb, Rails is going to look for class MyLib. Otherwise, you have to manually require the file when you want to use it.
So in your case, try moving MyClass out of the module, and make sure that the file is named lib/my_class.rb. That should take care of this problem.