About this site
Rails Helper Helper lets you run Rails' Action View helpers and see what they do. Pass arguments and options to see the resulting HTML, how the browser displays it, and what the form sends. The name means a helper for Rails' helpers.
About the output
- The HTML is rendered from the ERB on the server by Rails 8.1.4.1, the same way as an ordinary view.
- The params are what Rails builds on the server from the values the preview form sends.
- You can choose only the values set up for each page. The ERB does not accept arbitrary Ruby code.
- Rails is configured with
load_defaults 8.1. Where the output depends on configuration, it reflects these defaults. - This site has no database, so the persisted object you can choose for form_with's
model(Article.find(1)) is a stand-in returned by the model'sfind.
About the descriptions
The option descriptions are based on the actionview source and the actual output. For options with the same name as an HTML attribute, such as min and placeholder, the description says so when Rails changes the value or adds other HTML attributes.
The descriptions were written in Japanese. The English version is translated from the Japanese and may contain unnatural phrasing or shifts in meaning.
“Common options” are split into three groups, by the helpers they apply to.
- Shared by
…_field - Helpers whose names end in
_field, such astext_fieldandemail_field(those that inherit fromTags::TextField) - Shared by form helpers
- Form controls that build
nameandid. FormHelper builds them from the object name and the attribute name (Tags::Base), and FormTagHelper from thenameargument - Shared by all helpers
- All helpers that output tags (the rules of
TagHelper)
On the textarea and rich_textarea pages, the options shared by …_field that they handle the same way (placeholder) are shown as “Shared with …_field and others”.
What the pages leave out
This section covers Rails behavior that the pages leave out, for example because it is too detailed. These items were not checked as closely as the pages and may contain more mistakes.
Shared by form helpers
multiple: trueappends[]to thenameand adds themultipleattribute in other FormHelper helpers too, not justfile_field(checkbox only appends[]). In FormTagHelper, only select_tag appends[]. This lets several elements with the samenamesend multiple values. However, it was designed for elements such as select and file inputs, where a single element sends several values. Other helpers are not meant to be used this way, so among the…_fieldpages, onlyfile_fieldshows it.object,index,namespace,skip_default_idsandallow_method_names_outside_objectare options thatform_withandfields_forpass to the form builder methods. You do not pass them to each helper yourself, so the helper pages leave them out (namespace,index,skip_default_idsandallow_method_names_outside_objectare on theform_withpage).nilforindexadds[]instead of an index (text_field(:user, :name, index: nil)→name="user[][name]" id="user__name").- A
?at the end of the attribute name is removed from thenameandid(text_field(:user, :admin?)→name="user[admin]" id="user_admin"). - If
object_nameis in the"user[]"format, adds the object'sto_paramto thenameandidas an index. - When the object's value goes into
value, the value before type casting is used (the string exactly as the user typed it). If you enter "abc" in a text_field for a numeric attribute and the form is redisplayed with an error,valueis "abc" (because it reads<attribute>_before_type_cast). However, date_field, datetime_field, time_field, month_field and week_field use the type-cast value, reformatted, so if an unreadable value is entered and the form is redisplayed, there is novalueattribute. - With settings from before
load_defaults 8.1(config.action_view.remove_hidden_field_autocompleteset tofalse), also addsautocomplete="off"to hidden<input>elements. However, the hidden<input>elements of DateHelper (created withuse_hidden,discard_yearand the like) always getautocomplete="off", whatever the setting. - If the object has an error on that attribute, wraps the element in
<div class="field_with_errors">(hidden<input>elements are not wrapped).config.action_view.field_error_procchanges how it is wrapped. - If options include
type,…_fieldsets thetypeattribute to it (text_field(:user, :name, type: "email")→type="email"). Forcheckboxandradio_button, atypein options is overridden bycheckboxorradio. - If
namespaceis given to form_with or similar, theidis thenamespacevalue even whenid: nilis given. - If object_name differs from the model name, the translations for placeholder and label are also looked up under the model name (
helpers.placeholder.<model name>.<attribute>). For an Active Model model,activemodel.attributesis used instead ofactiverecord.attributes. - If
nameis given in options together withmultiple: true, no[]is appended and the given value is used as is (the same goes fornamein the html_options of select, collection_checkboxes and others). To send multiple values, write it asq[]. - Passing an endless range to
inof number_field or range_field raises RangeError, and a float range that excludes its end (1.0...2.5) raises TypeError. If bothinandwithinare given,withinbecomes an HTML attribute.
Shared by all helpers
- Escapes the content and HTML attribute values. Strings marked
html_safe(such as the output of other helpers) are not escaped (except that"in an HTML attribute value becomes"). - Boolean attributes (such as
disabled) are omitted when the value isfalseornil, and added otherwise, even for the string"false". For other attributes (those not in theBOOLEAN_ATTRIBUTESlist),falseis converted to a string too, giving values such astitle="false"; they are left out only when the value isnil. - In
aria:,trueandfalsebecome"true"and"false". - Passing something other than a hash to
data:adds a plaindataattribute. When the attribute name is written out in full ("data-foo_bar": 1),_is not replaced and the value is not converted to JSON.
checkbox
- If the
:checkedoption is omitted, compares the object's value with thechecked_valueargument. How it compares depends on the type (true/false, strings, arrays, etc.). - With
multiple: true,checked_valueis appended to theidafter replacing spaces and.with_, removing punctuation other than-and_, and downcasing it (Yes Pleasegivesarticle_published_yes_please). If options includeid, nothing is appended to theid, and the given value is used as is. - As with
disabledand the like, checkbox_tag and radio_button_tag add checked even for"true"or1.
checkbox_tag
- Unlike checkbox, does not add a hidden
<input>. - After
name, takes up to three arguments:value,checkedand options. Passing four or more raises an ArgumentError.
radio_button
- If
tag_valueis an empty string ornil, addscheckedeven without an object.
radio_button_tag
nameandvalueare required. After them, takes up to two arguments:checkedand options. Passing three or more raises an ArgumentError.
DateHelper
- Month names come from the
date.month_namestranslation.use_short_month: trueuses the short names (date.abbr_month_names), and an array of 12 names passed touse_month_namesis used instead. - Raises NoMethodError if the translation for the date order (
date.order) is missing: Rails passesdefault: []intending an empty array as the fallback, but I18n treats it as a list of fallback keys and returns a "translation missing" string instead. Rails ships English translations for the order and for the prompts (datetime.prompts). - If
with_css_classesgets a partial hash ({ year: "y" }), adds an emptyclass=""to the month and day<select>elements left out of the hash. - Raises ArgumentError if
start_yearandend_yearare more than 1000 years apart (max_years_allowedchanges the limit). - Passing
discard_type: trueto helpers with several<select>elements (date_select, select_date, etc.) gives every<select>the samename(userordate), so only the last value ends up in params. That is whydiscard_typeis shown only on pages such as select_year. - Passing
prefixto helpers with an object, such as date_select, uses the given value instead ofobject_nameas the prefix of thenameandid(prefix: "x"givesx[birthday(1i)]). A givenfield_nameis overridden bymethod. - When passing a hash as the first argument (
dateordatetime) of helpers such as select_date, the keys for minutes and seconds areminandsec. With the keysminuteandsecond, no<option>getsselected. - Passing the matching
discard_*(discard_day: truefor select_day) to a helper that creates a single<select>, such as select_year, creates a hidden<input>, asuse_hidden: truedoes. - Passing
include_position: trueto a helper that creates a single<select>, such as select_year, appends the position, such as(1i), to thenameandid(date[year(1i)]). This option is meant for internal use by date_select and others. - If several month text options are given together, only the first of
use_month_numbers,use_two_digit_numbers,add_month_numbersandmonth_format_stringis used. For the day,day_formatcomes beforeuse_two_digit_numbers. - distance_of_time_in_words gives
about 1 hourfrom 44 minutes 30 seconds,about 2 hoursfrom 89 minutes 30 seconds,1 dayfrom 23 hours 59 minutes 30 seconds,2 daysfrom 42 hours,about 1 monthfrom 29 days 23 hours 59 minutes 30 seconds, andabout 1 yearfrom 365 days.
email_field
- With
multiple: true, the browser sends a single comma-separated value, so params gets an array with one element. Comma-separated email addresses seem rarely needed, so the page leaves this out.
label
- The block receives a
LabelBuilder:translationreturns the translated string, andobjectreturns the form's object (label(:user, :plan) { |b| "#{b.translation} *" }). - The
nameoption shared by form helpers is dropped, andmultiplebecomes a plain HTML attribute. - Adding a translation for a
:value(helpers.label.user.plan.premium) makeshelpers.label.user.plana hash instead of a string, solabel(:user, :plan)without:valueconverts that hash to a string and uses it as the content ({premium: "Premium"}).
Helpers without a page
- cdata_section returns a
<![CDATA[…]]>string. In HTML, the browser reads it as a comment, so it cannot be shown in the HTML section. - csp_meta_tag creates a
<meta>with the CSP nonce. This site does not configure CSP, so it creates nothing.
csrf_meta_tags
- The
contentof thecsrf-token<meta>is a long string that changes on every render, so this site masks it as(hidden).
translate
- This site's
config/locales/examples/ja.ymlanden.ymlhold the example translations for the translate page. The page shows the file for its language, as is, above the ERB pane.
url_for, current_page?, link_to_unless_current
- Requests to this site's rendering API are
POST /api/render, so rendering with them as is would make current_page? alwaysfalse. These three pages therefore render with the request for openingGET /articles?page=2, shown above the ERB pane. - This site's
resources :articlesinconfig/routes.rb(ArticlesController) exists only so the examples on pages such as url_for and form_with can build URLs. Opening them returns nothing. - url_for adds no port when
portis 80 for http or 443 for https. - Passing
subdomain: falseto url_for removes the subdomain (blog.example.combecomesexample.com). If the host is an IP address,subdomainanddomainare ignored. - url_for treats
params.permit(…)(ActionController::Parameters) like a hash. Without permit, it raises ActionController::UnfilteredParameters. - If the current controller is in a namespace (such as
api/params), url_for looks forcontrollerin the same namespace. Starting it with/, as in"/articles", looks outside the namespace. - current_page? decodes
%20and the like before comparing (+is not decoded to a space). The query string is compared as a string, so a different order returnsfalse. - In link_to_unless_current,
check_parameters: trueormethodin the options hash is used by current_page? and removed from the URL.methodin html_options does not affect whether it is the current page.
AssetTagHelper
- This site's
app/assets/images/logo.png,logo@2x.png,app/assets/javascripts/application.jsandapp/assets/stylesheets/application.cssare assets for the page examples. They exist only so that the helpers can build digested paths, as in a real app.audios/chime.mp3andvideos/clip.mp4inapp/assets, andsound.mp3,sound.ogg,movie.mp4andmovie.webminpublic, are short audio and video clips for the audio_tag and video_tag previews to play. The files in the assets and in public differ in content, so you can tell which one was loaded.photo.pngandphoto.webpinpublicare images that show which one the image_tag, picture_tag and image_submit_tag previews loaded. - favicon_link_tag's
sourcedefaults to"favicon.ico", which is not among this site's assets, so omitting it raises Propshaft::MissingAssetError. The page therefore always passes it. - javascript_include_tag and stylesheet_link_tag also add an HTTP
Linkheader to the response ifconfig.action_view.preload_links_headeristrue(load_defaults 6.1and later). javascript_include_tag does not add it whendeferis given. preload_link_tag always adds it, whatever the setting. The:preload_links_headeroption (javascript_include_tag and stylesheet_link_tag only; preload_link_tag outputs it as a plain HTML attribute) and the:nopushoption change only this header, not the HTML, so the pages do not cover them. - Passing
extname: falseto javascript_include_tag and stylesheet_link_tag looks up the asset without adding the extension, which raises Propshaft::MissingAssetError. - On its own, Rails merges duplicate sources passed to javascript_include_tag and stylesheet_link_tag. Propshaft overrides both helpers and passes the sources to Rails one at a time, so in an app that uses Propshaft, like this site, passing the same string twice outputs two
<script>or<link>tags (javascript_include_tag("application", "application")). This can happen when the list of sources is built in code. - stylesheet_link_tag also takes
nonce, as javascript_include_tag does (truefor the CSP nonce,falsefor none, and a string as is). This site does not configure CSP, so the page does not cover it.
asset_path, asset_url
- If
config.relative_url_rootis set (for an app served from a subdirectory), it is prepended to the path unless the source is a URL or already starts with it. The same goes for tag helpers such as image_tag. It isnilon this site. host(andconfig.asset_host) can also be a proc. It is called with the path, and its return value is used as the host (if it takes a second argument, the current request is passed too; if it returnsnil, asset_path adds no host and asset_url adds the current request's).
button_to
- With a block, each argument moves up one position, and the block's output becomes the content of the
<button>(button_to("/articles", class: "x") do … end). The pages do not cover the block form. - In apps where
config.action_view.button_to_generates_button_tagisfalse(beforeload_defaults 7.0), creates<input type="submit">instead of<button>and sets itsvalueto thenameargument. This site usestrue. - Setting
config.action_view.prepend_content_exfiltration_preventiontotrueprepends HTML such as<!-- '"` -->to the<form>to close any attributes and tags left open. form_tag and form_with do the same. This site uses the default,false.
link_to
- With a block, each argument moves up one position, and the block's output becomes the content (
link_to("/articles", class: "x") do … end). The pages do not cover the block form. - An
hrefin html_options is used instead of the URL from options.
link_to_if, link_to_unless
- With a block, returns the block's output when it does not create the
<a>. The block receives thenameargument, orname,optionsandhtml_optionsif it takes two or more arguments. When the<a>is created, the block is ignored. The pages do not cover the block form.
phone_to, sms_to
- With a block, the block's output becomes the content of the
<a>, as in mail_to. The pages do not cover the block form.
mail_to
- With a block, the block's output becomes the content of the
<a>(mail_to("me@example.com") do … end). If thenameargument is also given,nameis ignored. The pages do not cover the block form.
TextHelper
- With a block, highlight calls the block for each match instead of using
highlighter, and replaces the match with the block's output (unlike\1inhighlighter, neither the match nor the output is escaped). With a block, truncate appends the block's output, but only when it truncates the text (the output does not count toward the length, and is escaped unless it ishtml_safe, even withescape: false). The pages do not cover the block form. - cycle returns the given values one at a time, in order, each time it is called (for example, to color table rows alternately). A single call does not show this, so there is no page for it.
- If truncate's
lengthis shorter thanomission, it returns justomission(three characters,..., even withlength: 2).separatoralso accepts a regular expression. - simple_format adds no
<br />to newlines at the start and end of the text.\r\nand\ralso count as newlines. - If word_wrap's
break_sequencecontains\1or\0, it is read as a replacement pattern, and the helper returnsnil. - If pluralize's
countisnil, it writes0(0 people). - excerpt strips whitespace from both ends of the result. If
textorphraseisnil, it returnsnil.
NumberHelper
- number_to_human's
unitsalso accepts the translation scope of the unit names (such as"number.human.decimal_units.units"). Hash keys must be symbols (:unit,:thousand, etc.); string keys raise an error. - On the Japanese page, number_to_human_size uses Rails' built-in English format, but 1 byte is also
Bytes(the English translation givesByte). - Even for a value that is not a number, number_to_phone adds delimiters if it ends in a run of digits (
"tel 5551234"givestel 555-1234).
SanitizeHelper
- Because this site uses
load_defaults 8.1, sanitize, strip_tags and strip_links use the HTML5 sanitizer (config.action_view.sanitizer_vendor). The HTML4 sanitizer behaves differently; for example, its strip_tags also removes the content of<script>. - sanitize's
scrubberalso accepts a Loofah scrubber name (such as:prune).
tag
- There is also a legacy form with positional arguments (
tag(name, options = nil, open = false, escape = true)). The Rails documentation says this form will be deprecated in a future version of Rails. - In the legacy form, every element is self-closed with
/>, whatever its type (tag(:br)gives<br />,tag(:div)gives<div />). Setting the third argument,open, totrueends the tag with>instead (<div class="x">). - The second argument,
options, becomes HTML attributes, like the options oftag.div. Setting the fourth argument,escape, tofalseleaves attribute values unescaped._in the element name is not turned into-(<my_element />).
token_list
- Escapes the tokens. Strings that are already escaped, such as
&, are unescaped once before escaping, so they are not escaped twice. Unlike other helpers, it also escapes strings markedhtml_safe. - Unlike passing an array or a hash to
classin other helpers (tag.div(class: ["btn", {active: true}])), splits strings at spaces and merges duplicate tokens.
javascript_tag
- With a block, uses the block's output as the content. In that case, a hash as the first argument becomes html_options (a string is ignored). The page does not cover the block form.
- A
]]>in the content is split into]]]]><![CDATA[>so that the CDATA section does not end early.
collection_checkboxes
- The
:readonlyoption, like:disabled, accepts a value, an array of values or a proc. It addsreadonlyto the matching checkboxes, but per the HTML spec, areadonlycheckbox can still be checked and unchecked. - Passing
idin html_options gives every checkbox'sidand every<label>'sforthe same value. - Passing
disabled: truein html_options does not add it to the hidden<input>at the top, so an empty value is still sent. - Passing
indexin html_options puts the index in the checkboxes'name, but not in thenameof the hidden<input>at the top. Passing it in options does the opposite: only the hidden<input>gets it. b.checkboxandb.labelin the block take a hash of HTML attributes (keys also in html_options get the html_options value). The same goes forb.radio_buttonin collection_radio_buttons.
collection_radio_buttons
- Passing an array to the
:checkedoption addscheckedto every matching radio button (two forchecked: [1, 2]). - The
:readonlyoption, andid,disabledandindexin html_options, are the same as in collection_checkboxes. A radio button can still be selected even withreadonly.
collection_select
- If
value_methodis a proc, also passing a proc to the:selectedor:disabledoption raises TypeError where that proc returns true. - If an item of collection is an array, a hash in it becomes HTML attributes of that item's
<option>([[1, "A", { class: "x" }]]with:firstand:second). The same goes for collection_checkboxes, collection_radio_buttons and options_from_collection_for_select, and it takes precedence over the same keys in html_options.
grouped_collection_select
- If
option_key_methodis a proc, also passing a proc to the:selectedor:disabledoption raises TypeError where that proc returns true. Same as collection_select.
grouped_options_for_select
- Passing a hash together with
divideralso lists the group names (the keys) as ordinary<option>elements. - Passing an array that is not in the grouped format (
%w[basic pro]) raises NoMethodError.
fields_for
- In FormBuilder's
f.fields_for, arecord_namein the"comments[]"format uses theidofrecord_objectas the index, as inarticle[comments][1][body]. record_namealso accepts an object instead of a symbol (fields_for @comment). This is the same as using the model name (comment) as the prefix of thenameandidand passing the object asrecord_object.- FormHelper's
fields_fordoes not treat a hash passed asrecord_objectas options (FormBuilder'sf.fields_fordoes).fields_for :comment, index: 1uses the hash as the object, so fields such asc.text_field :bodyraise NoMethodError when they read the value. Whenrecord_nameis an object (fields_for @comment, index: 1), the hash is not used, so neither are the options. To pass options as well, passnilasrecord_object, as infields_for :comment, nil, index: 1. - If FormBuilder's
f.fields_forgets noinclude_id, it uses theinclude_idgiven to the outer form (form_with, or the outerf.fields_forwhen nested). The form_with page does not list this option, but when it is passed as inform_with(model: @article, include_id: false), the innerf.fields_foruses that value. Passingskip_id: trueto form_with orf.fieldsis the same asinclude_id: false(passing it tof.fields_forhas no effect).
fields
fieldsis a version of fields_for that is called the same way as form_with (fields(:author, model: @author)). The only differences are thatallow_method_names_outside_objectdefaults totrue, and thatconfig.action_view.form_with_generates_idsdecides theidof the elements created in the block. It was added in Rails 5.1, alongside form_with, to replace fields_for, but it never did, and both remain. It behaves much like fields_for, and as far as a GitHub search shows, real apps rarely use it, so there is no page for fields.
f.button
- If
scopeorasis given to the outer form, that value becomes the prefix of thenameandidwhen thevalueargument is a symbol (post[draft]). The translation key for the content also changes: it looks uphelpers.submit.post.createinstead ofhelpers.submit.article.create.namespaceis prepended only to theidbuilt from the symbol. - If the outer form has no object (such as
form_with(url: "/search")), it looks up thehelpers.submit.submittranslation for the content and appends thescopename, as inSave Postwith Rails' English translations, orSubmit Postwithout a translation. Withoutscopeeither, a trailing space is left afterSave. - Whether
formmethodis rewritten depends on whether the value containspostorget, so a value such as"postx"is not rewritten.
f.submit
- A symbol passed as the
valueargument is only converted to a string and used as thevalueattribute (f.submit :draftgivesvalue="draft"). Unlike f.button, does not create anameorid. - Passing
:valueoverrides thevalueattribute, butdata-disable-withstays the string of the first argument,value(f.submit "Save", value: "Other"givesvalue="Other" data-disable-with="Save"). - Passing
formmethod: :deleteaddsformmethod="delete"as is. Unlike f.button, does not rewrite it into_method. - Setting
config.action_view.automatically_disable_submit_tagtofalsestops it from addingdata-disable-with. The setting defaults totrue. - A block is ignored without raising an error.
- As with f.button, if the enclosing form is given
scopeoras, the translation is looked up under that name (helpers.submit.post.create). data: { disable_with: false }adds nodata-disable-with. If"data-disable-with"is also given in options, that one is used.- The
typeoption changestype="submit"(such astype: "button").
field_id, field_name
- Passing field_id an
object_nameending in[], such as"article[comments][]", gives two_in a row:article_comments__title. - Unlike field_id, field_name uses the object's
to_sas the prefix when given a model object (#<Article:0x…>[tags]).
file_field
- The hidden
<input>frominclude_hiddensends an empty value to Active Storage'shas_many_attachedso that all attachments can be removed. Sending the edit form without choosing a file removes the current attachments. - The hidden
<input>frominclude_hiddengets onlyname; unlike in checkbox, it does not getdisabledorform. So even when the file<input>has thedisabledattribute, the hidden<input>'s empty value is sent and the current attachments are removed. - Called as
f.file_fieldon a form builder, it addsenctype="multipart/form-data"to the enclosing form_with or form_for (also inside a nestedf.fields_for). Calling file_field directly does not.
rich_textarea
<and>in the block's content are not escaped when it goes into thevalueof the hidden<input>. If the:valueoption is given or the object has a value, the block is ignored.- Even when
disabled, Trix accepts dropped and pasted files (Trix also makes the hidden<input>disabled, so they are not sent).
options_for_select
- Passing a proc as the
selectedargument does not addselectedto any<option>; unlike collection_select, it does not call the proc. - Passing the grouped format (
{ "Free" => ["basic"] }) ascontainercreates an<option>withvalue="["basic"]"instead of an<optgroup>. For groups, use grouped_options_for_select. - A string passed as
containeris returned as is.
options_from_collection_for_select
- If
value_methodis a proc, also passing a proc as theselectedargument (or in a hash with the keysselectedanddisabled) raises TypeError where that proc returns true. Same as collection_select.
option_groups_from_collection_for_select
- If
option_key_methodis a proc, also passing a proc asselected_key(or in a hash with the keysselectedanddisabled) raises TypeError where that proc returns true. Same as grouped_collection_select.
search_field
- Older versions of Safari supported the HTML attributes
autosave(the name under which recent searches are saved) andresults(how many recent searches to list). Passingautosavealso addsresults="10"if there is noresults. Testing in Safari on macOS did not reveal what they do, and no information could be found, so the page leaves them out. Passingautosave: true, which should use the host name reversed as the value, raises NameError (Tags::SearchField in Rails 8.1.4.1 has norequest).
select
- With a block, uses the block's output as the content of the
<select>instead ofchoices, andchoicescan be omitted (select(:user, :plan) do … end). choicesalso accepts a range (with1..3, the text andvalueare1,2and3).requiredin html_options adds an empty<option>only when there is nomultipleandsizeis 1.- Passing both the
:promptand:include_blankoptions adds both<option>elements. Passingdisabled: ""orselected: ""along with them addsdisabledorselectedto theprompt<option>. - With
multiple: true,disabledin html_options is also added to the hidden<input>at the top. The same goes for collection_select and grouped_collection_select.
select_tag
- Unlike select, passing
requiredin options does not add an empty<option>, and passingmultiple: truedoes not add a hidden<input>with an emptyvalue. - Appends
[]to thenameonly whenmultipleistrue.multiple: "multiple"adds themultipleattribute but not[]. - Passing both
promptandinclude_blankadds both, with theprompt<option>first.
form_with
- Without a block, outputs only the opening
<form>tag and the hidden<input>elements, without</form>. You write the content and</form>yourself. authenticity_tokenalso accepts a string, which is used as is for thevalueof the hidden<input>that holds the CSRF token.localdefaults totrue, anddata-remote="true"is not added, becauseconfig.action_view.form_with_generates_remote_formsisfalse(load_defaults 6.1and later).skip_enforcing_utf8: falseorenforce_utf8: trueadds a hidden<input>withname="utf8"(whose value is ✓), which makes old browsers send the form in UTF-8. If neither is given, it is not added, becauseconfig.action_view.default_enforce_utf8isfalse(load_defaults 6.0and later).
time_zone_select
- Passing a class that responds to
allto the:modeloption uses the list from that class'sallinstead ofActiveSupport::TimeZone. - The third argument of time_zone_options_for_select,
model, works like the:modeloption of time_zone_select. - Passing an array of name strings (
["Tokyo"]) topriority_zonesraises NoMethodError. PassActiveSupport::TimeZoneobjects or a regular expression. The same goes for time_zone_options_for_select. - The object's value and
defaultare compared as name strings ("Tokyo"). AnActiveSupport::TimeZoneobject selects nothing.
textarea
- Adds a newline before the content. In HTML, a newline right after
<textarea>is ignored, so this keeps the newline when the content starts with one (such as text whose first line is empty). If the content does not start with a newline, the added one is ignored and nothing changes.
weekday_select
- Day names come from the
date.day_namestranslation. Rails ships only English translations, so in other locales it raises NoMethodError unless you provide translations, such as those from rails-i18n. - Added in Rails 7.0.
- A block is accepted but ignored. It does not raise an error either.