Skip to content

Instantly share code, notes, and snippets.

@cschneid
Created August 5, 2009 17:17
Show Gist options
  • Select an option

  • Save cschneid/162840 to your computer and use it in GitHub Desktop.

Select an option

Save cschneid/162840 to your computer and use it in GitHub Desktop.
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "rails", "app", "models")
# Grab our own vendored copies of AR & AS. I had to hack AS to play nicely with <library>
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "vendor", "rails", "activesupport", "lib")
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "vendor", "rails", "activerecord", "lib")
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'rubygems'
require 'yaml'
# Fix timezone support in Active Record
require 'activerecord'
Time.zone = "Pacific Time (US & Canada)"
ActiveRecord::Base.time_zone_aware_attributes = true
ActiveRecord::Base.default_timezone = "Pacific Time (US & Canada)"
# Require all your models
require 'users'
#.....
# Setup the ruby environment
environment = ARGV[0] || "production"
puts "Loading environment: #{environment}"
db = YAML::load(File.open("../rails/config/database.yml").read)[environment]
ActiveRecord::Base.establish_connection(
db
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment