In Rails, I can create models which are global (accessible anywhere in the application). However, I’d like to create some constructs that are global, but don’t correspond to any database table (which is why they can’t be models) and won’t ever be instantiated (so I need modules instead of classes).
I’ve tried using the initializers directory, which works, but is annoying because it requires restarting my server every time I change a value (whereas I can change the code in my models without restarting the server). What’s the best way to create globally-accessible modules in this manner?
Just put it into
libsub-directory and add that to yourconfig/application.rb: