问题
I have the following case:
I want to be able to run an independent Ruby script as a daemon. I would like to be able to execute this script in the context/environment of my Rails project (so that the script can have access to the back-end/my Rails models, for example).
Is there a straightforward way to accomplish this?
Thanks!
回答1:
Use rails runner.
You could also create a rake task.
来源:https://stackoverflow.com/questions/18452714/execute-ruby-worker-script-in-rails-environment