From 54b9f5d9afcb102b33f7f604eb6da15d8b75f6e9 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Thu, 24 Mar 2011 03:22:20 +1100 Subject: (#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 --- lib/puppet/rails/inventory_node.rb | 5 +++++ 1 file changed, 5 insertions(+) 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], -- cgit