I have a Rails task: should I use script/runner or rake?

后端 未结 8 575
萌比男神i
萌比男神i 2020-12-07 16:08

For ad hoc Rails tasks we have a few implementation alternatives, chief among which would seem to be:

script/runner some_useful_thing
8条回答
  •  一生所求
    2020-12-07 17:08

    One thing I've done is just write normal ruby scripts and put them in the script/maintenance directory.

    All you need to do to load rails and get access to all your models, etc, is put require '../../config/environment.rb' at the top of your file, then you're away.

提交回复
热议问题