diff --git a/lib/rails_admin/abstract_model.rb b/lib/rails_admin/abstract_model.rb index ddb9c9a139..2401a9ed68 100644 --- a/lib/rails_admin/abstract_model.rb +++ b/lib/rails_admin/abstract_model.rb @@ -29,12 +29,15 @@ def self.all_models # Given a string +model_name+, finds the corresponding model class def self.lookup(model_name) - begin - (model = model_name.constantize rescue nil) && model.is_a?(Class) && (superclasses(model).include?(ActiveRecord::Base) ? model : nil) || nil - rescue LoadError - Rails.logger.error "Error while loading '#{model_name}': #{$!}" + model = model_name.constantize rescue nil + if model && model.is_a?(Class) && superclasses(model).include?(ActiveRecord::Base) && !model.abstract_class? + model + else nil end + rescue LoadError + Rails.logger.error "Error while loading '#{model_name}': #{$!}" + nil end def initialize(model) diff --git a/spec/dummy_app/app/models/abstract.rb b/spec/dummy_app/app/models/abstract.rb new file mode 100644 index 0000000000..54c5fa21d0 --- /dev/null +++ b/spec/dummy_app/app/models/abstract.rb @@ -0,0 +1,5 @@ +class Abstract < ActiveRecord::Base + + self.abstract_class = true + +end