Sha256: 0895071223eabff8421f00423ad85d75f161e2a0cc3ca1ec2744e17f5e0e321c
Contents?: true
Size: 752 Bytes
Versions: 16
Compression:
Stored size: 752 Bytes
Contents
class MediaInput < SimpleForm::Inputs::FileInput def input(wrapper_options) # :preview_version is a custom attribute from :input_html hash, so you can pick custom sizes version = input_html_options.delete(:preview_version) out = '' # the output string we're going to build # append file input. it will work accordingly with your simple_form wrappers (out << @builder.file_field(attribute_name, input_html_options)).html_safe # check if there's an uploaded file (eg: edit mode or form not saved) if object.send("#{attribute_name}?") # append preview image to output out << template.image_tag(object.send(attribute_name).tap {|o| break o.send(version) if version}.send('url')) end return out end end
Version data entries
16 entries across 16 versions & 1 rubygems