I put my batch file in lib folder and use rails db configuration, active-record like this.
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
when excute batch
ruby lib/batch.rb
in development environment it's ok
but production environment still save development database...
how do i set rails_env batch.rb like this
ruby lib/batch.rb RAILS_ENV=production