Class: UploaderInput
- Inherits:
-
Formtastic::Inputs::FileInput
- Object
- Formtastic::Inputs::FileInput
- UploaderInput
- Defined in:
- app/inputs/uploader_input.rb
Instance Method Summary collapse
- #base_id ⇒ Object
- #cache_html ⇒ Object
- #existing_html ⇒ Object
- #file_html ⇒ Object
- #method_present? ⇒ Boolean
- #replace_html ⇒ Object
- #to_html ⇒ Object
- #wrapper_html_options ⇒ Object
Instance Method Details
#base_id ⇒ Object
47 48 49 |
# File 'app/inputs/uploader_input.rb', line 47 def base_id [:id] || method end |
#cache_html ⇒ Object
16 17 18 |
# File 'app/inputs/uploader_input.rb', line 16 def cache_html builder.hidden_field("#{method}_cache_id", :value => object.send("cached_#{method}").try(:id), :id => "#{base_id}_cache") end |
#existing_html ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/inputs/uploader_input.rb', line 24 def existing_html if method_present? existing = template.content_tag(:span, object.send("cached_#{method}").try(:original_filename)) template.content_tag(:div, :id => "#{base_id}_existing", :class => 'cache_existing') do template.link_to(existing, Rails.application.routes.url_helpers.file_upload_cache_cached_file_path(object.send("cached_#{method}").try(:id))) << template.content_tag(:span, " replace", :id => "#{base_id}_replace") end end or "".html_safe end |
#file_html ⇒ Object
20 21 22 |
# File 'app/inputs/uploader_input.rb', line 20 def file_html builder.file_field(method, .merge(:class => 'cached_file', :id => base_id)) end |
#method_present? ⇒ Boolean
6 7 8 |
# File 'app/inputs/uploader_input.rb', line 6 def method_present? object.send(method).present? end |
#replace_html ⇒ Object
34 35 36 |
# File 'app/inputs/uploader_input.rb', line 34 def replace_html file_html end |
#to_html ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/inputs/uploader_input.rb', line 38 def to_html input_wrapping do label_html << cache_html << existing_html << file_html end end |
#wrapper_html_options ⇒ Object
10 11 12 13 14 |
# File 'app/inputs/uploader_input.rb', line 10 def super.tap do || [:class] << " present" if method_present? end end |