I have my own classes, which I want to use in my rake task. Where to put files with this classes?
Asked
Active
Viewed 1,452 times
4
-
You'll have to be a bit more specific as to what you're trying to achieve. Right now, all we can tell you is: "Somewhere where you instruct rake to find them". So if that's not sufficient, more details. – jer Aug 30 '11 at 22:09
1 Answers
3
If the classes are only used by the rake task, I'd keep them in lib/
, just make sure you are loading the directory by configuring autoload_paths
:
# application.rb
config.autoload_paths += %W(#{config.root}/lib)

dwhalen
- 1,927
- 12
- 11
-
5You don't *need* to use `autoload_paths`, you can just as easily `require` those files you need in the Rake task. By using `autoload_paths` you are forcing those files to be loaded *all the time*. – Ryan Bigg Aug 30 '11 at 23:24
-
Yes, better to `require` them since they're only needed in the rake task. – dwhalen Aug 31 '11 at 04:11