I wrote a module which contains some methods for doing math functions.
I want the module to be included in one of my rails models.
Where is the best place to put it?
if you put it under RAILS_ROOT/lib directory and assuming the name of
the file and the name of the module match, then it will be automatically
added by rails to the load_path and you can use it directly throughout
your rails application.
in recent versions of rails you can also add directories to the
load_path directly by tweaking environment.rb (look at the code, there
is a commented out example in there). But if we want convention over
configuration i’d recommend lib.
about making it a gem/plugin, I’d only do it if it’s going to be
something really generic that you are going to be reusing in several
projects. If not, it’s not worth the overwork.
Estamos de estreno… si necesitas llevar el control de tus gastos
visita http://www.gastosgem.com !!Es gratis!!