puts "Started merb_init.rb ..."
require 'active_record'
ActiveRecord::Base.verification_timeout = 14400
ActiveRecord::Base.logger = MERB_LOGGER

puts "Loading Gems (before framework) ..."
Merb::Gems.load_required(:before)

$LOAD_PATH.unshift(File.join(MERB_ROOT, "lib"))

puts "Loading Application..."
MERB_PATHS.each do |glob|
Dir[MERB_ROOT + glob].each { |m| require m }
end

puts "Loading Gems (after framework) ..."
Merb::Gems.load_required(:after)

#Get Database Config
puts "Connecting to database..."
conn_options = YAML::load(Erubis::Eruby.new(IO.read("#{MERB_ROOT}/config/database.yml")).result(binding))
ActiveRecord::Base.establish_connection conn_options["#{MERB_ENV}"]

#Get Environment File
require "#{MERB_ROOT}/config/environments/#{MERB_ENV}"

#
# Add your own ruby code here for app specific stuff. This file gets loaded
# after the framework is loaded.