From 8139e2241038baf9b72452056fcdc7c340d79275 Mon Sep 17 00:00:00 2001 From: Jacques Crocker Date: Fri, 16 Oct 2009 22:42:27 -0700 Subject: [PATCH] [merb-admin] Datamapper tweaks. Added support for namespaced models. --- lib/abstract_model.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/abstract_model.rb b/lib/abstract_model.rb index f2eb15d..d63c370 100644 --- a/lib/abstract_model.rb +++ b/lib/abstract_model.rb @@ -19,7 +19,7 @@ def self.all end @models.sort!{|a, b| a.model.to_s <=> b.model.to_s} when :datamapper - DataMapper::Resource.descendants.each do |m| + DataMapper::Model.descendants.each do |m| # Remove DataMapperSessionStore because it's included by default next if m == Merb::DataMapperSessionStore if Merb.const_defined?(:DataMapperSessionStore) model = lookup(m.to_s.to_sym) @@ -34,7 +34,7 @@ def self.all # Given a symbol +model_name+, finds the corresponding model class def self.lookup(model_name) begin - model = const_get(model_name) + model = Object.full_const_get(model_name.to_s) rescue NameError raise "MerbAdmin could not find model #{model_name}" end