Class: Effective::TableRows::FileField

Inherits:
Effective::TableRow show all
Defined in:
app/models/effective/table_rows/file_field.rb

Instance Attribute Summary

Attributes inherited from Effective::TableRow

#builder, #name, #options, #template

Instance Method Summary collapse

Methods inherited from Effective::TableRow

#controller_namespace, #hint, #initialize, #label, #label_content, #to_html, #tr_class, #value

Constructor Details

This class inherits a constructor from Effective::TableRow

Instance Method Details

#contentObject



7
8
9
10
11
12
13
14
15
# File 'app/models/effective/table_rows/file_field.rb', line 7

def content
  values = Array(value) - [nil, '']

  if values.length > 1
    values.map { |file| (:div, link_to_file(file)) }.join.html_safe
  elsif values.length == 1
    link_to_file(values.first)
  end
end


17
18
19
# File 'app/models/effective/table_rows/file_field.rb', line 17

def link_to_file(file)
  link_to(file.filename, template.url_for(file), target: '_blank')
end