Created
August 12, 2010 15:19
-
-
Save zachwaugh/521133 to your computer and use it in GitHub Desktop.
Loading rails environment in a script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Load Rails | |
ENV['RAILS_ENV'] = ARGV[0] || 'production' | |
DIR = File.dirname(__FILE__) | |
require DIR + '/../config/environment' | |
# ... do stuff that requires using your rails models |
@giddie require File.expand_path('../config/environment', File.dirname(__FILE__))
worked for me too, thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my 2 cents
executes
hello.rb
as if it is a part of rails app