加载rails环境的通常办法

#!/usr/bin/env ruby

# Set your environment here.
ENV["RAILS_ENV"] ||= "production"

require File.dirname(__FILE__) + "/../../config/environment"

puts "Rails was loaded!"



rb /lib/tasks/file.rb RAILS_ENV=development


通常用runner
rails runner your_script_here.rb

你可能感兴趣的:(Ruby,Rails,env)