diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-08-03 16:35:55 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-08-03 16:40:18 -0400 |
commit | f1648f6539a2fd74c9c53a08f886813b5f1c14ba (patch) | |
tree | 7850124a1c66bc22438aa39a01e77406fd9befcc /actionview/lib/action_view | |
parent | 422ec4cb78cc9c10af97ddf958d477ce604b4506 (diff) | |
download | rails-f1648f6539a2fd74c9c53a08f886813b5f1c14ba.tar.gz rails-f1648f6539a2fd74c9c53a08f886813b5f1c14ba.tar.bz2 rails-f1648f6539a2fd74c9c53a08f886813b5f1c14ba.zip |
Refactor convert_direct_upload_option_to_url
Also make sure file_field doesn't mutate the original options passed in.
Diffstat (limited to 'actionview/lib/action_view')
-rw-r--r-- | actionview/lib/action_view/helpers/form_helper.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb index 41af6b6e3a..ac42de053c 100644 --- a/actionview/lib/action_view/helpers/form_helper.rb +++ b/actionview/lib/action_view/helpers/form_helper.rb @@ -9,7 +9,6 @@ require_relative "../model_naming" require_relative "../record_identifier" require "active_support/core_ext/module/attribute_accessors" require "active_support/core_ext/hash/slice" -require "active_support/core_ext/hash/compact" require "active_support/core_ext/string/output_safety" require "active_support/core_ext/string/inflections" @@ -1194,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, convert_direct_upload_option_to_url(options)).render + Tags::FileField.new(object_name, method, self, convert_direct_upload_option_to_url(options.dup)).render end # Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by +method+) @@ -2319,7 +2318,9 @@ module ActionView 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 + if options.delete(:direct_upload) + options['data-direct-upload-url'] = rails_direct_uploads_url + end end end end |