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

+ (Object) find_for_resource_in_namespace(resource, namespace)



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

def self.find_for_resource_in_namespace(resource, namespace)
  where resource_type: resource_type(resource),
        resource_id:   resource_id_cast(resource),
        namespace:     namespace.to_s
end

+ (Object) resource_id_cast(record)

Postgres adapters won't compare strings to numbers (issue 34)



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

def self.resource_id_cast(record)
  resource_id_type == :string ? record.id.to_s : record.id
end

+ (Object) resource_id_type



33
34
35
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 33

def self.resource_id_type
  columns.detect{ |i| i.name == "resource_id" }.type
end

+ (Object) resource_type(resource)



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

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

Instance Method Details

- (Object) set_resource_type



37
38
39
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 37

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