aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2017-07-31 16:23:37 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2017-07-31 16:23:37 -0500
commitba12811db22de23e935b43f39cac8da523fa0ded (patch)
treed0f03c908f4df608e9da8c06cfb9f77638263f2a /actionview/lib/action_view/helpers/form_helper.rb
parent5beb87c7b1689212848b14a3977dad7d3514f30a (diff)
downloadrails-ba12811db22de23e935b43f39cac8da523fa0ded.tar.gz
rails-ba12811db22de23e935b43f39cac8da523fa0ded.tar.bz2
rails-ba12811db22de23e935b43f39cac8da523fa0ded.zip
Move the direct_upload: true convenience option from the activestorage helper into actionview
Diffstat (limited to 'actionview/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/form_helper.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb
index 4eac086a87..314a2e3f44 100644
--- a/actionview/lib/action_view/helpers/form_helper.rb
+++ b/actionview/lib/action_view/helpers/form_helper.rb
@@ -1193,7 +1193,7 @@ module ActionView
# file_field(:attachment, :file, class: 'file_input')
# # => <input type="file" id="attachment_file" name="attachment[file]" class="file_input" />
def file_field(object_name, method, options = {})
- Tags::FileField.new(object_name, method, self, options).render
+ Tags::FileField.new(object_name, method, self, convert_direct_upload_option_to_url(options)).render
end
# Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by +method+)
@@ -2316,6 +2316,10 @@ module ActionView
options[:include_id] = !options.delete(:skip_id)
end
end
+
+ def convert_direct_upload_option_to_url(options)
+ options.merge('data-direct-upload-url': options.delete(:direct_upload) ? rails_direct_uploads_url : nil).compact
+ end
end
end