Class: ActionView::Helpers::FormBuilder
- Inherits:
-
Object
- Object
- ActionView::Helpers::FormBuilder
- Defined in:
- lib/carrierwave-filepickerio/form_builder.rb
Instance Method Summary collapse
-
#fp_file_field(method, text = nil, options = {}) ⇒ Object
Returns a input tag tailored for a Filepicker.io upload widget to be attached for the form object.
- #fp_save_button(method, text, mime, options = {}, &block) ⇒ Object
Instance Method Details
#fp_file_field(method, text = nil, options = {}) ⇒ Object
Returns a input tag tailored for a Filepicker.io upload widget to be attached for the form object
6 7 8 9 |
# File 'lib/carrierwave-filepickerio/form_builder.rb', line 6 def fp_file_field(method, text=nil, ={}) method = "remote_#{method.to_s}_url".to_sym if !method.to_s.ends_with?('_url') @template.fp_file_field(@object_name, method, text, ) end |
#fp_save_button(method, text, mime, options = {}, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/carrierwave-filepickerio/form_builder.rb', line 11 def (method, text, mime, ={}, &block) method = "#{method.to_s}_url".to_sym if !method.to_s.ends_with?('_url') [:type]='button' # The URL value being used is not absolute, which is required by filepicker.io. So pull out the value # from the object now, and make it full relative to the current asset host value = .fetch(:value){ ::ActionView::Helpers::InstanceTag::value_before_type_cast(@object, method.to_s) } value &&= ERB::Util.html_escape(value) [:value] = @template.asset_path(value) # If no asset host is set create a full url form the request if !([:value].starts_with?('http://') || [:value].starts_with?('https://')) [:value] = @template.instance_eval "request.protocol + request.host_with_port + asset_path(value)" end @template.(@object, method, text, mime, , &block) end |