run a script in production

ruby-on-rails

Solution

RAILS_ENV=production rails r script/foo.rb

Problem

I would like to run a script in production. This script generates a record and inserts it into the production db. My problem is that the script tries to insert the record into the development db. run_report.rb ``` ENV['RAILS_ENV'] = 'production' require 'rubygems' require 'daemons' Daemons.run('report.rb') ``` report.rb ``` ENV['RAILS_ENV'] = 'production' ... @r = Report.new(:info => @info) @r.save ``` I've tried: script/rails runner run_report.rb start script/rails runner run_report.rb start production

Original source