We were using helper methods inside the model; we might as well include them in the model and use them from anywhere else. Note we're using a different logic for images and documents methods. That's because for images the logic was defined in the helper methods, but for documents the logic is defined in the Documentable concern. In the past, different documentable classes allowed different content types, while imageable classes have always allowed the same content types. I'm not sure which method is better; for now, I'm leaving it the way it was (except for the fact that we're removing the helper methods).
20 lines
392 B
Ruby
20 lines
392 B
Ruby
class Images::NestedComponent < ApplicationComponent
|
|
attr_reader :f, :image_fields
|
|
|
|
def initialize(f, image_fields: :image)
|
|
@f = f
|
|
@image_fields = image_fields
|
|
end
|
|
|
|
private
|
|
|
|
def imageable
|
|
f.object
|
|
end
|
|
|
|
def note
|
|
t "images.form.note", accepted_content_types: Image.humanized_accepted_content_types,
|
|
max_file_size: Image.max_file_size
|
|
end
|
|
end
|