Module: Decidim::Comments::Export

Defined in:
decidim-comments/lib/decidim/comments/export.rb

Class Method Summary collapse

Class Method Details

.comments_for_resource(resource_class, component) ⇒ Object

Public: Given a resource class and a component, returns the comments for that resource in that component.

resource_class - The resource’s Class component - The component where the resource is scoped to.

Returns an Arel::Relation with all the comments for that component and resource.



13
14
15
16
17
18
19
# File 'decidim-comments/lib/decidim/comments/export.rb', line 13

def comments_for_resource(resource_class, component)
  Comment
    .not_deleted
    .not_hidden
    .where(decidim_root_commentable_id: resource_class.where(component:))
    .where(decidim_root_commentable_type: resource_class.to_s)
end