Runner in Ruby on Rails

From the Rails Guides:

1.7 rails runner

runner runs Ruby code in the context of Rails non-interactively. For
instance:

$ rails runner "Model.long_running_method"

You can also use the alias “r” to invoke the runner: rails r.

You can specify the environment in which the runner command should
operate using the -e switch.

$ rails runner -e staging "Model.long_running_method"

Any code to be run must be loaded as a part of your Rails app, i.e. either in app/ or lib/, among other places.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)