views:

28

answers:

2

I have seen examples where it is put in the lib folder, and another example in the app folder. Is there standard place where it should be put for Rails 2.3.8 and Rails 3 convention?

A: 

Scripts have to go into the /scripts folder. Of course there's almost always the confusion as to how to differentiate a script from a regular ruby file that is 'required' by a controller/model. If your script is required to start/sustain your application, then yes its a script. Or else if its a ruby file that is need at times or just for some cases wherein it complements the model/controller, you're better off putting it in the /lib folder.

Shreyas Satish
are you sure? the scripts the `script` folder seem very "system" like or "Rails" like -- internal to Rails.
動靜能量
Absolutely. If your script stands by the definition of the script as mentioned above, it should definitely be in the /scripts folder.
Shreyas Satish
A: 

I usually don't have runner scripts, but instead directly call some method that exists either on a model or in something in lib. For example, my Rails cronjobs typically look like this:

/path_to_app/scripts/runner -e production "SomeModule.perform_task"

I think this is cleaner.

I wrote a script on one one occasion, though, and in that case, I just put it in the lib directory:

/path_to_app/scripts/runner -e production /path_to_app/lib/perform_task.rb"

John Douthat