railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.9k stars 2.26k forks source link

belongs_to_association.rb throws exception if model belongs to abstract class #2926

Open VladislavShved opened 7 years ago

VladislavShved commented 7 years ago

NoMethodError at /world~science~research undefined method 'properties' for nil:NilClass

block in <class:BelongsToAssociation> rails_admin (1.1.1) lib/rails_admin/config/fields/types/belongs_to_association.rb, line 19

at

@searchable ||= associated_model_config.abstract_model.properties.collect(&:name).include?(associated_model_config.object_label_method) ? [associated_model_config.object_label_method, {abstract_model.model => method_name}] : {abstract_model.model => method_name}

associated_model_config.abstract_model returns Nil

For example:

class Item < ActiveRecord::Base
  belongs_to :shop
end

class Shop < ActiveRecord::Base
  self.abstract_class = true

  has_many :items
end
VladislavShved commented 7 years ago

Fixed at my fork https://github.com/VladislavShved/rails_admin