Module: Uploadcare::Rails::ActionView::UploadcareUploaderTags
- Defined in:
- lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb
Overview
A module containing a view field helper
Constant Summary collapse
- DEFAULT_FIELD_OPTIONS =
A view helper to add a uploader button to a html-page See uploadcare.com/docs/uploads/file-uploader/#using-on-page for more info.
Example:
<%= uploadcare_uploader_field :post, :title %> => <input role="uploadcare-uploader" data-multiple="true" type="hidden" name="post[file]" id="post_file"> <div class="uploadcare--widget uploadcare--widget_status_ready" ...
Arguments:
object_name: (String/Symbol) - object name which a field belongs to method_name: (String/Symbol) - object method name options: (Hash, default: {}) - options for hidden_field
{ role: 'uploadcare-uploader' }.freeze
Instance Method Summary collapse
- #uploadcare_uploader_field(object_name, method_name, options = {}) ⇒ Object
- #uploadcare_uploader_field_tag(object_name, options = {}) ⇒ Object
- #uploadcare_uploader_options(options = {}) ⇒ Object
Instance Method Details
#uploadcare_uploader_field(object_name, method_name, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb', line 26 def uploadcare_uploader_field(object_name, method_name, = {}) hidden_field( object_name, method_name, ( .reverse_merge(multiple: uploadcare_uploader_multiple?(object_name, method_name).presence) ) ) end |
#uploadcare_uploader_field_tag(object_name, options = {}) ⇒ Object
36 37 38 |
# File 'lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb', line 36 def uploadcare_uploader_field_tag(object_name, = {}) hidden_field_tag(object_name, [:value], ()) end |
#uploadcare_uploader_options(options = {}) ⇒ Object
40 41 42 43 |
# File 'lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb', line 40 def ( = {}) = .transform_keys { |key| "data-#{key.to_s.underscore.dasherize}" } DEFAULT_FIELD_OPTIONS.merge() end |