How do I run Ruby tasks that use my Rails models?

后端 未结 9 1487
醉梦人生
醉梦人生 2021-02-01 08:58

I have a Rails app with some basic models. The website displays data retrieved from other sources. So I need to write a Ruby script that creates new instances in my database. I

9条回答
  •  轮回少年
    2021-02-01 09:00

    Check out my answer in "A cron job for rails: best practices?".

    It contains two examples for using cron to run Rake tasks and class methods (via script/runner). In both cases, Rails is loaded and you can use your models.

提交回复
热议问题