summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-06 19:03:05 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-06 19:03:05 +0000
commit46d344b9daa24047b60183cc94509d306b6b562a (patch)
tree3c11eaad696ba3d6e6dd40bd7b9e7d1a4a71af85 /lib/puppet/rails.rb
parent68233706a9ff05be8fa8ab3ab7198cd0918517d6 (diff)
downloadpuppet-46d344b9daa24047b60183cc94509d306b6b562a.tar.gz
puppet-46d344b9daa24047b60183cc94509d306b6b562a.tar.xz
puppet-46d344b9daa24047b60183cc94509d306b6b562a.zip
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
Diffstat (limited to 'lib/puppet/rails.rb')
-rw-r--r--lib/puppet/rails.rb40
1 files changed, 22 insertions, 18 deletions
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'