Skip to content

Commit

Permalink
ignore models that are abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
peymano committed Oct 19, 2011
1 parent 849898f commit e42ecbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/rails_admin/abstract_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions spec/dummy_app/app/models/abstract.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Abstract < ActiveRecord::Base

self.abstract_class = true

end

0 comments on commit e42ecbd

Please sign in to comment.