lib/active_wrapper/db.rb in active_wrapper-0.2.0 vs lib/active_wrapper/db.rb in active_wrapper-0.2.1

- old
+ new

@@ -5,12 +5,17 @@ def initialize(options) @base = options[:base] if File.exists?(path = "#{base}/config/database.yml") @config = YAML::load(File.open(path)) + else + raise "Could not find #{path}" end @env = options[:env].to_s + unless config[env] + raise "Environment \"#{env}\" not found in #{path}" + end end def connected? ActiveRecord::Base.connected? end @@ -34,9 +39,10 @@ ActiveRecord::Base.establish_connection(env) end end def migrate(version=nil) + establish_connection redirect_stdout do ActiveRecord::Migrator.migrate("#{base}/db/migrate", version) end end \ No newline at end of file