From 46d344b9daa24047b60183cc94509d306b6b562a Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 6 Mar 2007 19:03:05 +0000 Subject: Merging the webserver_portability branch from version 2182 to version 2258. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2259 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/rails.rb | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'lib/puppet/rails.rb') diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb index bb4781c0e..274861b8b 100644 --- a/lib/puppet/rails.rb +++ b/lib/puppet/rails.rb @@ -29,6 +29,27 @@ module Puppet::Rails } ) + def self.connect + # This global init does not work for testing, because we remove + # the state dir on every test. + unless ActiveRecord::Base.connected? + Puppet.config.use(:puppet) + + ActiveRecord::Base.logger = Logger.new(Puppet[:railslog]) + ActiveRecord::Base.allow_concurrency = true + ActiveRecord::Base.verify_active_connections! + + begin + ActiveRecord::Base.establish_connection(database_arguments()) + rescue => detail + if Puppet[:trace] + puts detail.backtrace + end + raise Puppet::Error, "Could not connect to database: %s" % detail + end + end + end + # The arguments for initializing the database connection. def self.database_arguments args = {:adapter => Puppet[:dbadapter]} @@ -54,24 +75,7 @@ module Puppet::Rails raise Puppet::DevError, "No activerecord, cannot init Puppet::Rails" end - # This global init does not work for testing, because we remove - # the state dir on every test. - unless ActiveRecord::Base.connected? - Puppet.config.use(:puppet) - - ActiveRecord::Base.logger = Logger.new(Puppet[:railslog]) - ActiveRecord::Base.allow_concurrency = true - ActiveRecord::Base.verify_active_connections! - - begin - ActiveRecord::Base.establish_connection(database_arguments()) - rescue => detail - if Puppet[:trace] - puts detail.backtrace - end - raise Puppet::Error, "Could not connect to database: %s" % detail - end - end + connect() unless ActiveRecord::Base.connection.tables.include?("resources") require 'puppet/rails/database/schema' -- cgit