diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2010-09-22 15:27:54 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-09-22 21:37:50 -0700 |
| commit | 6468f4ede9d96b8d83f107a8533a4ad6eb88c954 (patch) | |
| tree | 7a50588737141e2361d166fa5e102089f3834f0e /lib/puppet | |
| parent | 79d5fde2246cc20b0ace7ed3f273a5352931f6eb (diff) | |
| download | puppet-6468f4ede9d96b8d83f107a8533a4ad6eb88c954.tar.gz puppet-6468f4ede9d96b8d83f107a8533a4ad6eb88c954.tar.xz puppet-6468f4ede9d96b8d83f107a8533a4ad6eb88c954.zip | |
(#4763) Don't call a method that was removed in Rails 3 activerecord
Calling this method caused storeconfigs not to run.
ActiveRecord::Base.allow_concurrency was deprecated in Rails 2.2. We
support activerecord 2.1 and higher, so we still need to call this
method for 2.1. I factored out the code that determines our
activerecord version to a method in util so that the code was easier to
read and test.
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/feature/rails.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/rails.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/util.rb | 8 |
3 files changed, 12 insertions, 6 deletions
diff --git a/lib/puppet/feature/rails.rb b/lib/puppet/feature/rails.rb index 2763b0676..74ed09aa6 100644 --- a/lib/puppet/feature/rails.rb +++ b/lib/puppet/feature/rails.rb @@ -24,9 +24,7 @@ Puppet.features.add(:rails) do end end - if ! (defined?(::ActiveRecord) and defined?(::ActiveRecord::VERSION) and defined?(::ActiveRecord::VERSION::MAJOR) and defined?(::ActiveRecord::VERSION::MINOR)) - false - elsif ! (([::ActiveRecord::VERSION::MAJOR, ::ActiveRecord::VERSION::MINOR].join('.').to_f) >= 2.1) + unless (Puppet::Util.activerecord_version >= 2.1) Puppet.info "ActiveRecord 2.1 or later required for StoreConfigs" false else diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb index 6bf5d4abd..c2d492fdd 100644 --- a/lib/puppet/rails.rb +++ b/lib/puppet/rails.rb @@ -2,6 +2,7 @@ require 'facter' require 'puppet' +require 'logger' module Puppet::Rails TIME_DEBUG = true @@ -22,9 +23,8 @@ module Puppet::Rails ActiveRecord::Base.logger.level = Logger::DEBUG end - if (([::ActiveRecord::VERSION::MAJOR, ::ActiveRecord::VERSION::MINOR].join('.').to_f) >= 2.1) - ActiveRecord::Base.allow_concurrency = true - end + # As of ActiveRecord 2.2 allow_concurrency has been deprecated and no longer has any effect. + ActiveRecord::Base.allow_concurrency = true if Puppet::Util.activerecord_version < 2.2 ActiveRecord::Base.verify_active_connections! diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index bb4127089..f2eaf0d06 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -20,6 +20,14 @@ module Util # Create a hash to store the different sync objects. @@syncresources = {} + def self.activerecord_version + if (defined?(::ActiveRecord) and defined?(::ActiveRecord::VERSION) and defined?(::ActiveRecord::VERSION::MAJOR) and defined?(::ActiveRecord::VERSION::MINOR)) + ([::ActiveRecord::VERSION::MAJOR, ::ActiveRecord::VERSION::MINOR].join('.').to_f) + else + 0 + end + end + # Return the sync object associated with a given resource. def self.sync(resource) @@syncresources[resource] ||= Sync.new |
