actionview 7.0.0.rc3 → 7.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionview might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +54 -0
- data/MIT-LICENSE +1 -1
- data/lib/action_view/gem_version.rb +2 -2
- data/lib/action_view/helpers/asset_tag_helper.rb +8 -7
- data/lib/action_view/helpers/date_helper.rb +1 -1
- data/lib/action_view/helpers/form_helper.rb +12 -6
- data/lib/action_view/helpers/form_tag_helper.rb +15 -32
- data/lib/action_view/helpers/number_helper.rb +1 -0
- data/lib/action_view/helpers/tags/base.rb +3 -3
- data/lib/action_view/helpers/tags/file_field.rb +16 -0
- data/lib/action_view/helpers/url_helper.rb +23 -34
- data/lib/action_view.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2514d4c995366fdadafe620566090029761c449aa25b400802ab8150616451bb
|
4
|
+
data.tar.gz: e386f9582ec067004ac317616d519e11342cba217850721eb9b0164a52d64f27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2a769ea93e6f037039d3414f81785ce58b67cd762a11a3bf406c60aadc953e8ff8fd1b8a44bf8cd45d69fca7d330122de44a381ba514d9197de6fc640e089e2
|
7
|
+
data.tar.gz: bfbd0a092409bbe748e973d3d3d42ad5cd7fbc8f314866395a6a5bd368ff7aa49c7d6b78f063cc5249a68b90ada4f6192a76cfde838f98cbd9abacbcb1f0b837
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,53 @@
|
|
1
|
+
## Rails 7.0.2.1 (February 11, 2022) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 7.0.2 (February 08, 2022) ##
|
7
|
+
|
8
|
+
* Ensure `preload_link_tag` preloads JavaScript modules correctly.
|
9
|
+
|
10
|
+
*Máximo Mussini*
|
11
|
+
|
12
|
+
* Fix `stylesheet_link_tag` and similar helpers are being used to work in objects with
|
13
|
+
a `response` method.
|
14
|
+
|
15
|
+
*dark-panda*
|
16
|
+
|
17
|
+
|
18
|
+
## Rails 7.0.1 (January 06, 2022) ##
|
19
|
+
|
20
|
+
* Fix `button_to` to work with a hash parameter as URL.
|
21
|
+
|
22
|
+
*MingyuanQin*
|
23
|
+
|
24
|
+
* Fix `link_to` with a model passed as an argument twice.
|
25
|
+
|
26
|
+
*Alex Ghiculescu*
|
27
|
+
|
28
|
+
|
29
|
+
## Rails 7.0.0 (December 15, 2021) ##
|
30
|
+
|
31
|
+
* Support `include_hidden:` option in calls to
|
32
|
+
`ActionView::Helper::FormBuilder#file_field` with `multiple: true` to
|
33
|
+
support submitting an empty collection of files.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
form.file_field :attachments, multiple: true
|
37
|
+
# => <input type="hidden" autocomplete="off" name="post[attachments][]" value="">
|
38
|
+
<input type="file" multiple="multiple" id="post_attachments" name="post[attachments][]">
|
39
|
+
|
40
|
+
form.file_field :attachments, multiple: true, include_hidden: false
|
41
|
+
# => <input type="file" multiple="multiple" id="post_attachments" name="post[attachments][]">
|
42
|
+
```
|
43
|
+
|
44
|
+
*Sean Doyle*
|
45
|
+
|
46
|
+
* Fix `number_with_precision(raise: true)` always raising even on valid numbers.
|
47
|
+
|
48
|
+
*Pedro Moreira*
|
49
|
+
|
50
|
+
|
1
51
|
## Rails 7.0.0.rc3 (December 14, 2021) ##
|
2
52
|
|
3
53
|
* No changes.
|
@@ -5,6 +55,10 @@
|
|
5
55
|
|
6
56
|
## Rails 7.0.0.rc2 (December 14, 2021) ##
|
7
57
|
|
58
|
+
* No changes.
|
59
|
+
|
60
|
+
## Rails 7.0.0.rc1 (December 06, 2021) ##
|
61
|
+
|
8
62
|
* Support `fields model: [@nested, @model]` the same way as `form_with model:
|
9
63
|
[@nested, @model]`.
|
10
64
|
|
data/MIT-LICENSE
CHANGED
@@ -258,14 +258,14 @@ module ActionView
|
|
258
258
|
#
|
259
259
|
# The helper gets the name of the favicon file as first argument, which
|
260
260
|
# defaults to "favicon.ico", and also supports +:rel+ and +:type+ options
|
261
|
-
# to override their defaults, "
|
261
|
+
# to override their defaults, "icon" and "image/x-icon"
|
262
262
|
# respectively:
|
263
263
|
#
|
264
264
|
# favicon_link_tag
|
265
|
-
# # => <link href="/assets/favicon.ico" rel="
|
265
|
+
# # => <link href="/assets/favicon.ico" rel="icon" type="image/x-icon" />
|
266
266
|
#
|
267
267
|
# favicon_link_tag 'myicon.ico'
|
268
|
-
# # => <link href="/assets/myicon.ico" rel="
|
268
|
+
# # => <link href="/assets/myicon.ico" rel="icon" type="image/x-icon" />
|
269
269
|
#
|
270
270
|
# Mobile Safari looks for a different link tag, pointing to an image that
|
271
271
|
# will be used if you add the page to the home screen of an iOS device.
|
@@ -275,7 +275,7 @@ module ActionView
|
|
275
275
|
# # => <link href="/assets/mb-icon.png" rel="apple-touch-icon" type="image/png" />
|
276
276
|
def favicon_link_tag(source = "favicon.ico", options = {})
|
277
277
|
tag("link", {
|
278
|
-
rel: "
|
278
|
+
rel: "icon",
|
279
279
|
type: "image/x-icon",
|
280
280
|
href: path_to_image(source, skip_pipeline: options.delete(:skip_pipeline))
|
281
281
|
}.merge!(options.symbolize_keys))
|
@@ -325,16 +325,17 @@ module ActionView
|
|
325
325
|
crossorigin = "anonymous" if crossorigin == true || (crossorigin.blank? && as_type == "font")
|
326
326
|
integrity = options[:integrity]
|
327
327
|
nopush = options.delete(:nopush) || false
|
328
|
+
rel = mime_type == "module" ? "modulepreload" : "preload"
|
328
329
|
|
329
330
|
link_tag = tag.link(**{
|
330
|
-
rel:
|
331
|
+
rel: rel,
|
331
332
|
href: href,
|
332
333
|
as: as_type,
|
333
334
|
type: mime_type,
|
334
335
|
crossorigin: crossorigin
|
335
336
|
}.merge!(options.symbolize_keys))
|
336
337
|
|
337
|
-
preload_link = "<#{href}>; rel
|
338
|
+
preload_link = "<#{href}>; rel=#{rel}; as=#{as_type}"
|
338
339
|
preload_link += "; type=#{mime_type}" if mime_type
|
339
340
|
preload_link += "; crossorigin=#{crossorigin}" if crossorigin
|
340
341
|
preload_link += "; integrity=#{integrity}" if integrity
|
@@ -542,7 +543,7 @@ module ActionView
|
|
542
543
|
MAX_HEADER_SIZE = 8_000 # Some HTTP client and proxies have a 8kiB header limit
|
543
544
|
def send_preload_links_header(preload_links, max_header_size: MAX_HEADER_SIZE)
|
544
545
|
return if preload_links.empty?
|
545
|
-
return if response
|
546
|
+
return if respond_to?(:response) && response&.sending?
|
546
547
|
|
547
548
|
if respond_to?(:request) && request
|
548
549
|
request.send_early_hints("Link" => preload_links.join("\n"))
|
@@ -1149,7 +1149,7 @@ module ActionView
|
|
1149
1149
|
|
1150
1150
|
# Builds hidden input tag for date part and value.
|
1151
1151
|
# build_hidden(:year, 2008)
|
1152
|
-
# => "<input id="
|
1152
|
+
# => "<input type="hidden" id="date_year" name="date[year]" value="2008" autocomplete="off" />"
|
1153
1153
|
def build_hidden(type, value)
|
1154
1154
|
select_options = {
|
1155
1155
|
type: "hidden",
|
@@ -478,6 +478,8 @@ module ActionView
|
|
478
478
|
|
479
479
|
mattr_accessor :form_with_generates_ids, default: false
|
480
480
|
|
481
|
+
mattr_accessor :multiple_file_field_include_hidden, default: false
|
482
|
+
|
481
483
|
# Creates a form tag based on mixing URLs, scopes, or models.
|
482
484
|
#
|
483
485
|
# # Using just a URL:
|
@@ -1214,6 +1216,7 @@ module ActionView
|
|
1214
1216
|
# * Creates standard HTML attributes for the tag.
|
1215
1217
|
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
|
1216
1218
|
# * <tt>:multiple</tt> - If set to true, *in most updated browsers* the user will be allowed to select multiple files.
|
1219
|
+
# * <tt>:include_hidden</tt> - When <tt>multiple: true</tt> and <tt>include_hidden: true</tt>, the field will be prefixed with an <tt><input type="hidden"></tt> field with an empty value to support submitting an empty collection of files.
|
1217
1220
|
# * <tt>:accept</tt> - If set to one or multiple mime-types, the user will be suggested a filter when choosing a file. You still need to set up model validations.
|
1218
1221
|
#
|
1219
1222
|
# ==== Examples
|
@@ -1232,7 +1235,9 @@ module ActionView
|
|
1232
1235
|
# file_field(:attachment, :file, class: 'file_input')
|
1233
1236
|
# # => <input type="file" id="attachment_file" name="attachment[file]" class="file_input" />
|
1234
1237
|
def file_field(object_name, method, options = {})
|
1235
|
-
|
1238
|
+
options = { include_hidden: multiple_file_field_include_hidden }.merge!(options)
|
1239
|
+
|
1240
|
+
Tags::FileField.new(object_name, method, self, convert_direct_upload_option_to_url(options.dup)).render
|
1236
1241
|
end
|
1237
1242
|
|
1238
1243
|
# Returns a textarea opening and closing tag set tailored for accessing a specified attribute (identified by +method+)
|
@@ -1744,8 +1749,8 @@ module ActionView
|
|
1744
1749
|
# <tt>aria-describedby</tt> attribute referencing the <tt><span></tt>
|
1745
1750
|
# element, sharing a common <tt>id</tt> root (<tt>post_title</tt>, in this
|
1746
1751
|
# case).
|
1747
|
-
def field_id(method, *suffixes, index: @index)
|
1748
|
-
@template.field_id(@object_name, method, *suffixes, index: index)
|
1752
|
+
def field_id(method, *suffixes, namespace: @options[:namespace], index: @index)
|
1753
|
+
@template.field_id(@object_name, method, *suffixes, namespace: namespace, index: index)
|
1749
1754
|
end
|
1750
1755
|
|
1751
1756
|
# Generate an HTML <tt>name</tt> attribute value for the given name and
|
@@ -2485,6 +2490,7 @@ module ActionView
|
|
2485
2490
|
# * Creates standard HTML attributes for the tag.
|
2486
2491
|
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
|
2487
2492
|
# * <tt>:multiple</tt> - If set to true, *in most updated browsers* the user will be allowed to select multiple files.
|
2493
|
+
# * <tt>:include_hidden</tt> - When <tt>multiple: true</tt> and <tt>include_hidden: true</tt>, the field will be prefixed with an <tt><input type="hidden"></tt> field with an empty value to support submitting an empty collection of files.
|
2488
2494
|
# * <tt>:accept</tt> - If set to one or multiple mime-types, the user will be suggested a filter when choosing a file. You still need to set up model validations.
|
2489
2495
|
#
|
2490
2496
|
# ==== Examples
|
@@ -2577,7 +2583,7 @@ module ActionView
|
|
2577
2583
|
# # => <button name='button' type='submit'>Create post</button>
|
2578
2584
|
#
|
2579
2585
|
# button(:draft, value: true)
|
2580
|
-
# # => <button name="post[draft]" value="true" type="submit">Create post</button>
|
2586
|
+
# # => <button id="post_draft" name="post[draft]" value="true" type="submit">Create post</button>
|
2581
2587
|
#
|
2582
2588
|
# button do
|
2583
2589
|
# content_tag(:strong, 'Ask me!')
|
@@ -2596,7 +2602,7 @@ module ActionView
|
|
2596
2602
|
# button(:draft, value: true) do
|
2597
2603
|
# content_tag(:strong, "Save as draft")
|
2598
2604
|
# end
|
2599
|
-
# # => <button name="post[draft]" value="true" type="submit">
|
2605
|
+
# # => <button id="post_draft" name="post[draft]" value="true" type="submit">
|
2600
2606
|
# # <strong>Save as draft</strong>
|
2601
2607
|
# # </button>
|
2602
2608
|
#
|
@@ -2605,7 +2611,7 @@ module ActionView
|
|
2605
2611
|
when Hash
|
2606
2612
|
value, options = nil, value
|
2607
2613
|
when Symbol
|
2608
|
-
value, options
|
2614
|
+
value, options = nil, { name: field_name(value), id: field_id(value) }.merge!(options.to_h)
|
2609
2615
|
end
|
2610
2616
|
value ||= submit_default_value
|
2611
2617
|
|
@@ -62,7 +62,7 @@ module ActionView
|
|
62
62
|
#
|
63
63
|
# <%= form_tag('/posts', remote: true) %>
|
64
64
|
# # => <form action="/posts" method="post" data-remote="true">
|
65
|
-
|
65
|
+
#
|
66
66
|
# form_tag(false, method: :get)
|
67
67
|
# # => <form method="get">
|
68
68
|
#
|
@@ -96,7 +96,7 @@ module ActionView
|
|
96
96
|
# <tt>aria-describedby</tt> attribute referencing the <tt><span></tt>
|
97
97
|
# element, sharing a common <tt>id</tt> root (<tt>post_title</tt>, in this
|
98
98
|
# case).
|
99
|
-
def field_id(object_name, method_name, *suffixes, index: nil)
|
99
|
+
def field_id(object_name, method_name, *suffixes, index: nil, namespace: nil)
|
100
100
|
if object_name.respond_to?(:model_name)
|
101
101
|
object_name = object_name.model_name.singular
|
102
102
|
end
|
@@ -105,16 +105,13 @@ module ActionView
|
|
105
105
|
|
106
106
|
sanitized_method_name = method_name.to_s.delete_suffix("?")
|
107
107
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
else
|
116
|
-
"#{sanitized_object_name}_#{sanitized_method_name}"
|
117
|
-
end
|
108
|
+
[
|
109
|
+
namespace,
|
110
|
+
sanitized_object_name.presence,
|
111
|
+
(index unless sanitized_object_name.empty?),
|
112
|
+
sanitized_method_name,
|
113
|
+
*suffixes,
|
114
|
+
].tap(&:compact!).join("_")
|
118
115
|
end
|
119
116
|
|
120
117
|
# Generate an HTML <tt>name</tt> attribute value for the given name and
|
@@ -297,14 +294,14 @@ module ActionView
|
|
297
294
|
#
|
298
295
|
# ==== Examples
|
299
296
|
# hidden_field_tag 'tags_list'
|
300
|
-
# # => <input
|
297
|
+
# # => <input type="hidden" name="tags_list" id="tags_list" autocomplete="off" />
|
301
298
|
#
|
302
299
|
# hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI@'
|
303
|
-
# # => <input
|
300
|
+
# # => <input type="hidden" name="token" id="token" value="VUBJKB23UIVI1UU1VOBVI@" autocomplete="off" />
|
304
301
|
#
|
305
302
|
# hidden_field_tag 'collected_input', '', onchange: "alert('Input collected!')"
|
306
|
-
# # => <input
|
307
|
-
#
|
303
|
+
# # => <input type="hidden" name="collected_input" id="collected_input"
|
304
|
+
# value="" onchange="alert('Input collected!')" autocomplete="off" />
|
308
305
|
def hidden_field_tag(name, value = nil, options = {})
|
309
306
|
text_field_tag(name, value, options.merge(type: :hidden, autocomplete: "off"))
|
310
307
|
end
|
@@ -345,7 +342,7 @@ module ActionView
|
|
345
342
|
# file_field_tag 'file', accept: 'text/html', class: 'upload', value: 'index.html'
|
346
343
|
# # => <input accept="text/html" class="upload" id="file" name="file" type="file" value="index.html" />
|
347
344
|
def file_field_tag(name, options = {})
|
348
|
-
text_field_tag(name, nil, convert_direct_upload_option_to_url(
|
345
|
+
text_field_tag(name, nil, convert_direct_upload_option_to_url(options.merge(type: :file)))
|
349
346
|
end
|
350
347
|
|
351
348
|
# Creates a password field, a masked text field that will hide the users input behind a mask character.
|
@@ -987,23 +984,9 @@ module ActionView
|
|
987
984
|
tag_options.delete("data-disable-with")
|
988
985
|
end
|
989
986
|
|
990
|
-
def convert_direct_upload_option_to_url(
|
987
|
+
def convert_direct_upload_option_to_url(options)
|
991
988
|
if options.delete(:direct_upload) && respond_to?(:rails_direct_uploads_url)
|
992
989
|
options["data-direct-upload-url"] = rails_direct_uploads_url
|
993
|
-
|
994
|
-
if options[:object] && options[:object].class.respond_to?(:reflect_on_attachment)
|
995
|
-
attachment_reflection = options[:object].class.reflect_on_attachment(name)
|
996
|
-
|
997
|
-
class_with_attachment = "#{options[:object].class.name.underscore}##{name}"
|
998
|
-
options["data-direct-upload-attachment-name"] = class_with_attachment
|
999
|
-
|
1000
|
-
service_name = attachment_reflection.options[:service_name] || ActiveStorage::Blob.service.name
|
1001
|
-
options["data-direct-upload-token"] = ActiveStorage::DirectUploadToken.generate_direct_upload_token(
|
1002
|
-
class_with_attachment,
|
1003
|
-
service_name,
|
1004
|
-
session
|
1005
|
-
)
|
1006
|
-
end
|
1007
990
|
end
|
1008
991
|
options
|
1009
992
|
end
|
@@ -97,7 +97,7 @@ module ActionView
|
|
97
97
|
options["name"] = options.fetch("name") { tag_name(options["multiple"], index) }
|
98
98
|
|
99
99
|
if generate_ids?
|
100
|
-
options["id"] = options.fetch("id") { tag_id(index) }
|
100
|
+
options["id"] = options.fetch("id") { tag_id(index, options.delete("namespace")) }
|
101
101
|
if namespace = options.delete("namespace")
|
102
102
|
options["id"] = options["id"] ? "#{namespace}_#{options['id']}" : namespace
|
103
103
|
end
|
@@ -108,8 +108,8 @@ module ActionView
|
|
108
108
|
@template_object.field_name(@object_name, sanitized_method_name, multiple: multiple, index: index)
|
109
109
|
end
|
110
110
|
|
111
|
-
def tag_id(index = nil)
|
112
|
-
@template_object.field_id(@object_name, @method_name, index: index)
|
111
|
+
def tag_id(index = nil, namespace = nil)
|
112
|
+
@template_object.field_id(@object_name, @method_name, index: index, namespace: namespace)
|
113
113
|
end
|
114
114
|
|
115
115
|
def sanitized_method_name
|
@@ -4,6 +4,22 @@ module ActionView
|
|
4
4
|
module Helpers
|
5
5
|
module Tags # :nodoc:
|
6
6
|
class FileField < TextField # :nodoc:
|
7
|
+
def render
|
8
|
+
include_hidden = @options.delete(:include_hidden)
|
9
|
+
options = @options.stringify_keys
|
10
|
+
add_default_name_and_id(options)
|
11
|
+
|
12
|
+
if options["multiple"] && include_hidden
|
13
|
+
hidden_field_for_multiple_file(options) + super
|
14
|
+
else
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def hidden_field_for_multiple_file(options)
|
21
|
+
tag("input", "name" => options["name"], "type" => "hidden", "value" => "", "autocomplete" => "off")
|
22
|
+
end
|
7
23
|
end
|
8
24
|
end
|
9
25
|
end
|
@@ -197,7 +197,7 @@ module ActionView
|
|
197
197
|
#
|
198
198
|
# * <tt>confirm: 'question?'</tt> - This will allow the unobtrusive JavaScript
|
199
199
|
# driver to prompt with the question specified (in this case, the
|
200
|
-
# resulting text would be <tt>question?</tt
|
200
|
+
# resulting text would be <tt>question?</tt>). If the user accepts, the
|
201
201
|
# link is processed normally, otherwise no action is taken.
|
202
202
|
# * <tt>:disable_with</tt> - Value of this parameter will be used as the
|
203
203
|
# name for a disabled version of the link. This feature is provided by
|
@@ -262,34 +262,24 @@ module ActionView
|
|
262
262
|
# be placed
|
263
263
|
# * <tt>:params</tt> - \Hash of parameters to be rendered as hidden fields within the form.
|
264
264
|
#
|
265
|
-
# ==== Data attributes
|
266
|
-
#
|
267
|
-
# * <tt>:confirm</tt> - This will use the unobtrusive JavaScript driver to
|
268
|
-
# prompt with the question specified. If the user accepts, the link is
|
269
|
-
# processed normally, otherwise no action is taken.
|
270
|
-
# * <tt>:disable_with</tt> - Value of this parameter will be
|
271
|
-
# used as the value for a disabled version of the submit
|
272
|
-
# button when the form is submitted. This feature is provided
|
273
|
-
# by the unobtrusive JavaScript driver.
|
274
|
-
#
|
275
265
|
# ==== Examples
|
276
266
|
# <%= button_to "New", action: "new" %>
|
277
267
|
# # => "<form method="post" action="/controller/new" class="button_to">
|
278
268
|
# # <button type="submit">New</button>
|
279
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
269
|
+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6" autocomplete="off"/>
|
280
270
|
# # </form>"
|
281
271
|
#
|
282
272
|
# <%= button_to "New", new_article_path %>
|
283
273
|
# # => "<form method="post" action="/articles/new" class="button_to">
|
284
274
|
# # <button type="submit">New</button>
|
285
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
275
|
+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6" autocomplete="off"/>
|
286
276
|
# # </form>"
|
287
277
|
#
|
288
278
|
# <%= button_to "New", new_article_path, params: { time: Time.now } %>
|
289
279
|
# # => "<form method="post" action="/articles/new" class="button_to">
|
290
280
|
# # <button type="submit">New</button>
|
291
281
|
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
292
|
-
# # <input type="hidden" name="time" value="2021-04-08 14:06:09 -0500">
|
282
|
+
# # <input type="hidden" name="time" value="2021-04-08 14:06:09 -0500" autocomplete="off">
|
293
283
|
# # </form>"
|
294
284
|
#
|
295
285
|
# <%= button_to [:make_happy, @user] do %>
|
@@ -299,37 +289,34 @@ module ActionView
|
|
299
289
|
# # <button type="submit">
|
300
290
|
# # Make happy <strong><%= @user.name %></strong>
|
301
291
|
# # </button>
|
302
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
292
|
+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6" autocomplete="off"/>
|
303
293
|
# # </form>"
|
304
294
|
#
|
305
295
|
# <%= button_to "New", { action: "new" }, form_class: "new-thing" %>
|
306
296
|
# # => "<form method="post" action="/controller/new" class="new-thing">
|
307
297
|
# # <button type="submit">New</button>
|
308
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
298
|
+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6" autocomplete="off"/>
|
309
299
|
# # </form>"
|
310
300
|
#
|
311
301
|
# <%= button_to "Create", { action: "create" }, remote: true, form: { "data-type" => "json" } %>
|
312
302
|
# # => "<form method="post" action="/images/create" class="button_to" data-remote="true" data-type="json">
|
313
303
|
# # <button type="submit">Create</button>
|
314
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
304
|
+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6" autocomplete="off"/>
|
315
305
|
# # </form>"
|
316
306
|
#
|
317
|
-
#
|
318
|
-
#
|
319
|
-
#
|
320
|
-
#
|
321
|
-
# # <button data-confirm='Are you sure?' type="submit">Delete Image</button>
|
322
|
-
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
|
323
|
-
# # </form>"
|
307
|
+
# ==== Deprecated: Rails UJS attributes
|
308
|
+
#
|
309
|
+
# Prior to Rails 7, Rails shipped with a JavaScript library called @rails/ujs on by default. Following Rails 7,
|
310
|
+
# this library is no longer on by default. This library integrated with the following options:
|
324
311
|
#
|
325
|
-
#
|
326
|
-
#
|
327
|
-
#
|
328
|
-
#
|
329
|
-
#
|
330
|
-
#
|
331
|
-
#
|
332
|
-
#
|
312
|
+
# * <tt>confirm: 'question?'</tt> - This will allow the unobtrusive JavaScript
|
313
|
+
# driver to prompt with the question specified (in this case, the
|
314
|
+
# resulting text would be <tt>question?</tt>). If the user accepts, the
|
315
|
+
# button is processed normally, otherwise no action is taken.
|
316
|
+
# * <tt>:disable_with</tt> - Value of this parameter will be
|
317
|
+
# used as the value for a disabled version of the submit
|
318
|
+
# button when the form is submitted. This feature is provided
|
319
|
+
# by the unobtrusive JavaScript driver.
|
333
320
|
def button_to(name = nil, options = nil, html_options = nil, &block)
|
334
321
|
html_options, options = options, name if block_given?
|
335
322
|
html_options ||= {}
|
@@ -366,7 +353,9 @@ module ActionView
|
|
366
353
|
html_options = convert_options_to_data_attributes(options, html_options)
|
367
354
|
html_options["type"] = "submit"
|
368
355
|
|
369
|
-
button = if block_given?
|
356
|
+
button = if block_given?
|
357
|
+
content_tag("button", html_options, &block)
|
358
|
+
elsif button_to_generates_button_tag
|
370
359
|
content_tag("button", name || url, html_options, &block)
|
371
360
|
else
|
372
361
|
html_options["value"] = name || url
|
@@ -743,7 +732,7 @@ module ActionView
|
|
743
732
|
end
|
744
733
|
|
745
734
|
def url_target(name, options)
|
746
|
-
if name.respond_to?(:model_name) && options.empty?
|
735
|
+
if name.respond_to?(:model_name) && options.is_a?(Hash) && options.empty?
|
747
736
|
url_for(name)
|
748
737
|
else
|
749
738
|
url_for(options)
|
data/lib/action_view.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c) 2004-
|
4
|
+
# Copyright (c) 2004-2022 David Heinemeier Hansson
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
# a copy of this software and associated documentation files (the
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 7.0.
|
19
|
+
version: 7.0.2.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 7.0.
|
26
|
+
version: 7.0.2.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,28 +92,28 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - '='
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 7.0.
|
95
|
+
version: 7.0.2.1
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - '='
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 7.0.
|
102
|
+
version: 7.0.2.1
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: activemodel
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - '='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 7.0.
|
109
|
+
version: 7.0.2.1
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - '='
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 7.0.
|
116
|
+
version: 7.0.2.1
|
117
117
|
description: Simple, battle-tested conventions and helpers for building web pages.
|
118
118
|
email: david@loudthinking.com
|
119
119
|
executables: []
|
@@ -246,10 +246,10 @@ licenses:
|
|
246
246
|
- MIT
|
247
247
|
metadata:
|
248
248
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
249
|
-
changelog_uri: https://github.com/rails/rails/blob/v7.0.
|
250
|
-
documentation_uri: https://api.rubyonrails.org/v7.0.
|
249
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.0.2.1/actionview/CHANGELOG.md
|
250
|
+
documentation_uri: https://api.rubyonrails.org/v7.0.2.1/
|
251
251
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
252
|
-
source_code_uri: https://github.com/rails/rails/tree/v7.0.
|
252
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.0.2.1/actionview
|
253
253
|
rubygems_mfa_required: 'true'
|
254
254
|
post_install_message:
|
255
255
|
rdoc_options: []
|
@@ -262,12 +262,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
262
|
version: 2.7.0
|
263
263
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
264
264
|
requirements:
|
265
|
-
- - "
|
265
|
+
- - ">="
|
266
266
|
- !ruby/object:Gem::Version
|
267
|
-
version:
|
267
|
+
version: '0'
|
268
268
|
requirements:
|
269
269
|
- none
|
270
|
-
rubygems_version: 3.2.
|
270
|
+
rubygems_version: 3.2.22
|
271
271
|
signing_key:
|
272
272
|
specification_version: 4
|
273
273
|
summary: Rendering framework putting the V in MVC (part of Rails).
|