Reputation: 305
I know the lib/
directory can be added to the autoload_paths
and eager_load_paths
quite easily. But I don't quite understand why files in lib/
are not autoloaded or eager loaded by default?
I can't find a simple answer anywhere unfortunately so I'd really appreciate if someone could explain this to me simply!
Upvotes: 1
Views: 957
Reputation: 239541
Because there is no Rails convention for putting files in lib
that require autoloading. lib
is for rake/thor tasks which reside lib/tasks
and little else.
Your application-specific files should go in app
. If you find yourself thinking of putting something in lib
, it probably belongs somewhere in app
, or in a Gem.
Upvotes: 4