Module: Decidim::Comments::Export

Defined in:
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
# File 'lib/decidim/comments/export.rb', line 13

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