templates/project/config/initialize.rb in sweetsie-0.1.0 vs templates/project/config/initialize.rb in sweetsie-0.1.1
- old
+ new
@@ -1,23 +1,26 @@
require 'rubygems'
require 'active_record'
+require 'logger'
-module Sweeetsie
+module Sweetsie
class << self
- def boot(enviornment)
+ SWET_ROOT = File.dirname(__FILE__)
+
+ def boot(environment)
ActiveRecord::Base.establish_connection(db[environment])
- ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'log', "#{environment}.log"))
+ ActiveRecord::Base.logger = Logger.new(File.join(SWET_ROOT, 'log', "#{environment}.log"))
- Dir[File.join(%W|#{File.dirname(__FILE__)} models ** *.rb |)].each {|r| load r}
+ Dir[File.join(SWET_ROOT, '..', 'models', '**', '*.rb')].each {|r| load r}
end
def migrations
- File.join(File.dirname(__FILE__), 'db', 'migrate')
+ File.join(SWET_ROOT, 'db', 'migrate')
end
def db
- YAML::load(File.read(File.join(File.dirname(__FILE__), 'database.yml')))
+ YAML::load(File.read(File.join(SWET_ROOT, '..', 'config', 'database.yml')))
end
def up!(version=nil)
ActiveRecord::Migration.migrate migrations, version
end