简体   繁体   English

在生产中运行脚本

[英]run a script in production

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 run_report.rb

 ENV['RAILS_ENV'] = 'production'
 require 'rubygems'
 require 'daemons'

 Daemons.run('report.rb')

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

script/rails runner run_report.rb start production 脚本/轨道运行器run_report.rb开始生产

RAILS_ENV=production rails r script/foo.rb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM