Class: ActiveAdmin::Comment

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

Class Method Summary collapse

Class Method Details

.find_for_resource_in_namespace(resource, namespace) ⇒ Object



30
31
32
33
34
# File 'lib/active_admin/comments/comment.rb', line 30

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

.resource_id_cast(record) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/active_admin/comments/comment.rb', line 21

def self.resource_id_cast(record)
  # Postgres adapters won't compare strings to numbers (issue 34)
  if resource_id_type == :string
    record.id.to_s
  else
    record.id
  end
end

.resource_id_typeObject



36
37
38
# File 'lib/active_admin/comments/comment.rb', line 36

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

.resource_type(record) ⇒ Object



17
18
19
# File 'lib/active_admin/comments/comment.rb', line 17

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

.table_nameObject



40
41
42
# File 'lib/active_admin/comments/comment.rb', line 40

def self.table_name
  @table_name ||= ActiveRecord::Migrator.proper_table_name("active_admin_comments")
end