Class: ActiveAdmin::Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveAdmin::Comment
- Defined in:
- lib/active_admin/comments/comment.rb
Class Method Summary collapse
- .find_for_resource_in_namespace(resource, namespace) ⇒ Object
- .resource_id_cast(record) ⇒ Object
- .resource_id_type ⇒ Object
- .resource_type(record) ⇒ Object
- .table_name ⇒ Object
Class Method Details
.find_for_resource_in_namespace(resource, namespace) ⇒ Object
25 26 27 28 29 |
# File 'lib/active_admin/comments/comment.rb', line 25 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
16 17 18 19 20 21 22 23 |
# File 'lib/active_admin/comments/comment.rb', line 16 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_type ⇒ Object
31 32 33 |
# File 'lib/active_admin/comments/comment.rb', line 31 def self.resource_id_type columns.detect{ |i| i.name == "resource_id" }.type end |
.resource_type(record) ⇒ Object
12 13 14 |
# File 'lib/active_admin/comments/comment.rb', line 12 def self.resource_type(record) record.class.base_class.name.to_s end |
.table_name ⇒ Object
35 36 37 |
# File 'lib/active_admin/comments/comment.rb', line 35 def self.table_name @table_name ||= ActiveRecord::Migrator.proper_table_name("active_admin_comments") end |