Sha256: 74f49174bcafe9880f767c93fa3691793327d89183edd836a0eb86fc0de710cd

Contents?: true

Size: 839 Bytes

Versions: 2

Compression:

Stored size: 839 Bytes

Contents

# This file handles all the background initialization work that the programmer
# shouldn't have to worry about.  
# This includes database startup, common requires, activesupport, and other
# magic.  I'm not sure if this is a good idea or not.

# ENV works like in rails, except is :real or :test
GTRON_ENV rescue GTRON_ENV = :real 
GTRON_ROOT = File.dirname(__FILE__)

#set up autoload paths
$: << "#{GTRON_ROOT}/lib/"

require 'rubygems'
require 'rake'

require 'active_record'

def get_db_conn(env)
  env = env.to_sym
  #set up logging
  ActiveRecord::Base.logger = Logger.new("#{GTRON_ROOT}/log/#{env}.log")

  #load in dbs from database.yml
  ActiveRecord::Base.establish_connection(
    YAML::load(File.read("#{GTRON_ROOT}/database.yml"))[env])

  #load all models
  Dir["#{GTRON_ROOT}/models/**/*.rb"].each {|r| load r }

  nil
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
michaelbarton-gigantron-0.1.4 app_generators/gigantron/templates/initialize.rb
michaelbarton-gigantron-0.1.7 templates/project/initialize.rb