Sha256: e9b8f52ba1e98edebc277c44928dafc7d4cc513d8389c9c379fbab2d85700988

Contents?: true

Size: 955 Bytes

Versions: 55

Compression:

Stored size: 955 Bytes

Contents

class Formtastic::Inputs::SingleFileInput
  include Formtastic::Inputs::Base

  def to_html
    object = builder.object
    model_instance = object.send(method)
    model_class = object.class.reflect_on_association(method).klass

    html = template.raw("")
    html << label_html
    html << builder.fields_for(method, model_class.new) do |f|
      f.file_field :asset, accept: model_class.extension_white_list, id: input_html_options[:id]
    end

    if model_instance
      html << template.content_tag(:div, class: "file-description") do
        filename = model_instance.asset.file.try(:filename)
        f_html = template.raw("")

        if model_class.to_s.include?("Image")
          f_html << template.content_tag(:img, "", src: model_instance.asset.lalala_thumb.url)
        end

        if filename
          f_html << template.content_tag(:span, filename)
        end

        f_html
      end
    end

    input_wrapping { html }
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
lalala-4.0.0.dev.336 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.331 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.329 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.313 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.291 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.288 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.285 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.284 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.283 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.279 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.277 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.275 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.269 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.267 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.264 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.260 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.258 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.256 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.255 lib/formtastic/inputs/single_file_input.rb
lalala-4.0.0.dev.254 lib/formtastic/inputs/single_file_input.rb