module Decidim::HasAttachments
A concern with the components needed when you want a model to be able to create links from it to another resource.
Public Instance Methods
attachment_context()
click to toggle source
Attachment context for the file uploaders checks (e.g. which kind of files the user is allowed to upload in this context).
Override this in the model class if it is for a different context.
Returns a Symbol.
# File lib/decidim/has_attachments.rb, line 53 def attachment_context :participant end
documents()
click to toggle source
All the attachments that are documents for this process.
Returns an Array<Attachment>
# File lib/decidim/has_attachments.rb, line 28 def documents @documents ||= attachments.includes(:attachment_collection).select(&:document?) end
documents_with_collection()
click to toggle source
All the attachments that are documents for this process that has a collection.
Returns an Array<Attachment>
# File lib/decidim/has_attachments.rb, line 35 def documents_with_collection documents.select(&:attachment_collection_id?) end
documents_without_collection()
click to toggle source
All the attachments that are documents for this process that not has a collection.
Returns an Array<Attachment>
# File lib/decidim/has_attachments.rb, line 42 def documents_without_collection documents.reject(&:attachment_collection_id?) end
photos()
click to toggle source
All the attachments that are photos for this process.
Returns an Array<Attachment>
# File lib/decidim/has_attachments.rb, line 21 def photos @photos ||= attachments.select(&:photo?) end