Skip to content

Instantly share code, notes, and snippets.

@zachwaugh
Created August 12, 2010 15:19
Show Gist options
  • Save zachwaugh/521133 to your computer and use it in GitHub Desktop.
Save zachwaugh/521133 to your computer and use it in GitHub Desktop.
Loading rails environment in a script
#!/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
@Eruanne2
Copy link

@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