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



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

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

.ransackable_associations(auth_object = nil) ⇒ Object



35
36
37
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 35

def self.ransackable_associations(auth_object = nil)
  authorizable_ransackable_associations
end

.ransackable_attributes(auth_object = nil) ⇒ Object



31
32
33
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 31

def self.ransackable_attributes(auth_object = nil)
  authorizable_ransackable_attributes
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



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

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

Instance Method Details

#set_resource_typeObject



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

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