4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/trestle/active_storage/field.rb', line 4
def field
instance = builder.object
attachment = instance.send(name)
rendering_options = {}.tap do |hash|
hash[:locals] = {}.tap do |locals|
locals[:builder] = builder
locals[:field_name] = name
if attachment.respond_to?(:each)
hash[:partial] = 'trestle/active_storage/has_many_field'
locals[:attachments] = attachment
else
hash[:partial] = 'trestle/active_storage/has_one_field'
locals[:attachment] = attachment
end
end
end
@template.render rendering_options
end
|