Module: S3Relay::UploadsHelper

Defined in:
app/helpers/s3_relay/uploads_helper.rb

Instance Method Summary collapse

Instance Method Details

#s3_relay_field(parent, association, opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/s3_relay/uploads_helper.rb', line 4

def s3_relay_field(parent, association, opts={})
  file_field     = file_field_tag(:file, opts.merge(class: "s3r-field"))
  progress_table = (:table, "", class: "s3r-upload-list")
  content        = [file_field, progress_table].join
  parent_type    = parent.class.to_s.underscore.downcase

  (:div, raw(content),
    {
      class: "s3r-container",
      data:  {
        parent_type: parent_type,
        parent_id:   parent.id.to_s,
        association: association.to_s,
        disposition: opts.fetch(:disposition, "inline")
      }
    }
  )
end