&tag(Rails4/バッチ処理);
config.autoload_paths += %W(#{config.root}/lib) # 追加class Tasks::HelloTask
def self.execute
print "Hello World!! env=#{Rails.env}\n"
end
end
bundle exec rails runner "Tasks::HelloTask.execute"
$ bundle exec rails runner --help
Usage: rails runner [options] [<'Some.ruby(code)'> | <filename.rb>]
-e, --environment=name Specifies the environment for the runner to operate under (test/development/production).
Default: development
-h, --help Show this help message.
export RACK_ENV="production"