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
32 33 34 35 36 |
# File 'lib/active_admin/comments/comment.rb', line 32 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
23 24 25 26 27 28 29 30 |
# File 'lib/active_admin/comments/comment.rb', line 23 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
38 39 40 |
# File 'lib/active_admin/comments/comment.rb', line 38 def self.resource_id_type columns.detect{ |i| i.name == "resource_id" }.type end |
.resource_type(record) ⇒ Object
19 20 21 |
# File 'lib/active_admin/comments/comment.rb', line 19 def self.resource_type(record) record.class.base_class.name.to_s end |
.table_name ⇒ Object
42 43 44 |
# File 'lib/active_admin/comments/comment.rb', line 42 def self.table_name @table_name ||= ActiveRecord::Migrator.proper_table_name("active_admin_comments") end |