Added alias method for ActiveRecord versions before 3.0

Signed-off-by: James Turnbull <[email protected]>
---
Local-branch: tickets/master/6818
 lib/puppet/rails/inventory_node.rb |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/puppet/rails/inventory_node.rb 
b/lib/puppet/rails/inventory_node.rb
index 52f8621..4cc975a 100644
--- a/lib/puppet/rails/inventory_node.rb
+++ b/lib/puppet/rails/inventory_node.rb
@@ -3,14 +3,18 @@ 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
 
-  named_scope :has_fact_with_value, lambda { |name,value|
+  if Puppet::Util.activerecord_version > 3.0
+    alias :scope :named_scope
+  end
+
+  scope :has_fact_with_value, lambda { |name,value|
     {
       :conditions => ["inventory_facts.name = ? AND inventory_facts.value = 
?", name, value],
       :joins => :facts
     }
   }
 
-  named_scope :has_fact_without_value, lambda { |name,value|
+  scope :has_fact_without_value, lambda { |name,value|
     {
       :conditions => ["inventory_facts.name = ? AND inventory_facts.value != 
?", name, value],
       :joins => :facts
-- 
1.7.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to