Skip to content

Instantly share code, notes, and snippets.

@jzellman
Created January 6, 2012 20:17
Show Gist options
  • Save jzellman/1572222 to your computer and use it in GitHub Desktop.
Save jzellman/1572222 to your computer and use it in GitHub Desktop.
How to do this Idiom in Rails 3
#!/usr/bin/env ruby
# works in rails 3
RAILS_ENV = ARGV[0]
if RAILS_ENV.nil?
puts "usage: blah.rb environment"
exit
end
ENV['RAILS_ENV'] = RAILS_ENV
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'application'))
puts Rails.env
# Do something smart here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment