Class: ActiveAdmin::Comment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/active_admin/orm/active_record/comments/comment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_for_resource_in_namespace(resource, namespace) ⇒ Object


18
19
20
21
22
23
24
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 18

def self.find_for_resource_in_namespace(resource, namespace)
  where(
    resource_type: resource_type(resource),
    resource_id: resource.id,
    namespace: namespace.to_s
  ).order(ActiveAdmin.application.namespaces[namespace.to_sym].comments_order)
end

.resource_type(resource) ⇒ String

Returns The name of the record to use for the polymorphic relationship.

Returns:

  • (String)

    The name of the record to use for the polymorphic relationship


14
15
16
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 14

def self.resource_type(resource)
  ResourceController::Decorators.undecorate(resource).class.base_class.name.to_s
end

Instance Method Details

#set_resource_typeObject


26
27
28
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 26

def set_resource_type
  self.resource_type = self.class.resource_type(resource)
end