Module: AbAdmin::Models::AdminComment::ClassMethods

Defined in:
lib/ab_admin/models/admin_comment.rb

Instance Method Summary collapse

Instance Method Details

#find_for_resource(resource) ⇒ Object


30
31
32
# File 'lib/ab_admin/models/admin_comment.rb', line 30

def find_for_resource(resource)
  where(resource_type: resource_type(resource), resource_id: resource.id).includes(:attachment_files)
end

#find_resource(resource_type, resource_id) ⇒ Object


34
35
36
# File 'lib/ab_admin/models/admin_comment.rb', line 34

def find_resource(resource_type, resource_id)
  resource_type.constantize.find(resource_id)
end

#resource_type(record) ⇒ Object


26
27
28
# File 'lib/ab_admin/models/admin_comment.rb', line 26

def resource_type(record)
  record.class.base_class.name.to_s
end