Reputation: 7038
I'm refactoring on old Rails app, and I have a lot of little methods\helpers that keep piling up that are not controller\model specific but are rather system-wide specific.
For instance I have a method that determines whether the system is Windows or not:
def windows?
(/win|mingw/).match(RUBY_PLATFORM) ? true : false
end
I use it in a few places to setup platform specific configuration, such as absolute executable path for wicked_pdf and gbarcode, etc, etc. The point is it's system wide and can be used anywhere.
Some people say put it in environment, some in lib, some in application helper, some say roll out a gem or plugin.
What is the consensus?
Upvotes: 1
Views: 333
Reputation: 5101
I use this post as a guideline.
Basically, anything not specific to controllers/models that is application specific, put in lib.
If the class/module will be used in multiple applications then make a gem/plugin.
Upvotes: 2