Skip to content

Commit

Permalink
[merb-admin] Datamapper tweaks. Added support for namespaced models.
Browse files Browse the repository at this point in the history
  • Loading branch information
merbjedi committed Oct 17, 2009
1 parent 183e09a commit 8139e22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/abstract_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

2 comments on commit 8139e22

@sferik
Copy link

@sferik sferik commented on 8139e22 Oct 17, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.