Move nested images partial to a component
This commit is contained in:
20
app/components/images/nested_component.rb
Normal file
20
app/components/images/nested_component.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class Images::NestedComponent < ApplicationComponent
|
||||
attr_reader :f, :image_fields
|
||||
delegate :imageable_humanized_accepted_content_types, :imageable_max_file_size, to: :helpers
|
||||
|
||||
def initialize(f, image_fields: :image)
|
||||
@f = f
|
||||
@image_fields = image_fields
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def imageable
|
||||
f.object
|
||||
end
|
||||
|
||||
def imageables_note
|
||||
t "images.form.note", accepted_content_types: imageable_humanized_accepted_content_types,
|
||||
max_file_size: imageable_max_file_size
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user