Class: ActiveAdmin::Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActiveAdmin::Comment
- Defined in:
- lib/active_admin/orm/active_record/comments/comment.rb
Class Method Summary collapse
- .find_for_resource_in_namespace(resource, namespace) ⇒ Object
- .ransackable_attributes(auth_object = nil) ⇒ Object
-
.resource_type(resource) ⇒ String
The name of the record to use for the polymorphic relationship.
Instance Method Summary collapse
Class Method Details
.find_for_resource_in_namespace(resource, namespace) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 18 def self.find_for_resource_in_namespace(resource, namespace) where( resource_type: resource_type(resource), resource_id: resource, namespace: namespace.to_s ).order(ActiveAdmin.application.namespaces[namespace.to_sym].comments_order) end |
.ransackable_attributes(auth_object = nil) ⇒ Object
26 27 28 |
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 26 def self.ransackable_attributes(auth_object = nil) ["author_id", "author_type", "body", "created_at", "id", "namespace", "resource_id", "resource_type", "updated_at"] end |
.resource_type(resource) ⇒ String
Returns The name of the record to use for the polymorphic relationship.
14 15 16 |
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 14 def self.resource_type(resource) ResourceController::Decorators.undecorate(resource).class.base_class.name.to_s end |
Instance Method Details
#set_resource_type ⇒ Object
30 31 32 |
# File 'lib/active_admin/orm/active_record/comments/comment.rb', line 30 def set_resource_type self.resource_type = self.class.resource_type(resource) end |