Robert W. wrote in post #1150810:
Ruby has a mechanism for this. They are called “gems”, libraries of
So you are suggesting to write a gem for this??? I would have not
expected this suggestion, but I will think about it.
Rails provides a “lib” directory for code more tightly
coupled with the application in which they are used.
I have noticed the lib directory, but I was a bit reluctant to use it,
because - if I understand it right - whenever I change something in a
file below lib, I would have to restart the rails server, which is
inconvenient during development.
If you do have
model classes that are not subclasses of ActiveRecord there’s still no
reason they can’t live inside the models directory along side your
Shouldn’t there (in models) be only classes related to - well -
“modelling”, i.e. related to a data model? For example, if I have a
class which represents a connection to separate processes (say, a proxy
to a Clearcase server), this wouldn’t fit well to the other stuff in the
Ruby also provides modules and mix-ins for adding functionality to
existing classes, this can often be a good way to implement utility
I guess you mean the files in helpers? Yes, this one I use already for
various utility functions, but helpers usually are targeted for views (I
can make them available in controllers, but they still would be
available in views too).
I see that there are several ways to do it. Could you also explain, why
my naive approach (to create a separate “lib” subdirectory below “app”
and put everything there) would be a bad idea? I have never seen someone
suggesting this, so I suspect it must have a drawback which I just don’t