Skip to content
Browse files

[merb-admin] Datamapper tweaks. Added support for namespaced models.

  • Loading branch information...
1 parent 183e09a commit 8139e2241038baf9b72452056fcdc7c340d79275 @merbjedi committed
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/abstract_model.rb
View
4 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

2 comments on commit 8139e22

@sferik

This patch looks good, but I'm reluctant to apply it until a non-edge version of Merb ships with dm-0.10.x. I know of people running MerbAdmin with merb-1.0.12/dm-0.9.11 in a corporate environment, who won't upgrade until 1.0.13/1.1 ships.

@merbjedi
Owner

Oops, good call. I should have separated that out into 2 patches. The safe one to include is the

Object.full_const_get(model_name.to_s)
Please sign in to comment.
Something went wrong with that request. Please try again.