diff options
author | Matt Robinson <matt@puppetlabs.com> | 2011-03-24 03:22:20 +1100 |
---|---|---|
committer | Matt Robinson <matt@puppetlabs.com> | 2011-04-11 15:16:57 -0700 |
commit | 54b9f5d9afcb102b33f7f604eb6da15d8b75f6e9 (patch) | |
tree | 278ae2b753fb99907c38869ff419356ec2dd5feb /lib/puppet/rails/inventory_node.rb | |
parent | 7b23e59f64d75158e067fa41f9d41c257aa0bc4b (diff) | |
download | puppet-54b9f5d9afcb102b33f7f604eb6da15d8b75f6e9.tar.gz puppet-54b9f5d9afcb102b33f7f604eb6da15d8b75f6e9.tar.xz puppet-54b9f5d9afcb102b33f7f604eb6da15d8b75f6e9.zip |
(#6818) Stop from getting Rails 3 named_scope deprecation warning
We want our Rails models in Puppet to work under Rails 2 or 3, but we
don't want the deprecation warnings since we can't control what version
of Rails the client is running.
DEPRECATION WARNING: Base.named_scope has been deprecated, please use
Base.scope instead
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'lib/puppet/rails/inventory_node.rb')
-rw-r--r-- | lib/puppet/rails/inventory_node.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/puppet/rails/inventory_node.rb b/lib/puppet/rails/inventory_node.rb index 52f8621a4..da7e61040 100644 --- a/lib/puppet/rails/inventory_node.rb +++ b/lib/puppet/rails/inventory_node.rb @@ -3,6 +3,11 @@ require 'puppet/rails/inventory_fact' class Puppet::Rails::InventoryNode < ::ActiveRecord::Base has_many :facts, :class_name => "Puppet::Rails::InventoryFact", :foreign_key => :node_id, :dependent => :delete_all + if Puppet::Util.activerecord_version >= 3.0 + # Prevents "DEPRECATION WARNING: Base.named_scope has been deprecated, please use Base.scope instead" + ActiveRecord::NamedScope::ClassMethods.module_eval { alias :named_scope :scope } + end + named_scope :has_fact_with_value, lambda { |name,value| { :conditions => ["inventory_facts.name = ? AND inventory_facts.value = ?", name, value], |