我把我的批处理文件放在lib文件夹 中,并使用rails db configuration,active-record像这样。如何设置脚本或批处理文件的rails_env
require "#{File.dirname(__FILE__)}/../config/environment.rb"
class Batch
def hello
Message.new do |t|
t.title = "hello"
t.save
end
end
end
batch = Batch.new
batch.hello
时EXCUTE一批
ruby lib/batch.rb
在开发环境中这是确定
,但生产环境还是节省开发数据库...
如何设置RAILS_ENV batch.rb这样
ruby lib/batch.rb RAILS_ENV=production
感谢非常有用的〜 – seapy 2010-02-08 17:49:37