actionview/lib/action_view/helpers/form_tag_helper.rb
# Generate an HTML <tt>id</tt> attribute value for the given name and
# field combination
#
# Return the value generated by the <tt>FormBuilder</tt> for the given
# attribute name.
#
#   <%= label_tag :post, :title %>
#   <%= text_field_tag :post, :title, aria: { describedby: field_id(:post, :title, :error) } %>
#   <%= tag.span("is blank", id: field_id(:post, :title, :error) %>
#
# In the example above, the <tt><input type="text"></tt> element built by
# the call to <tt>text_field_tag</tt> declares an
# <tt>aria-describedby</tt> attribute referencing the <tt><span></tt>
# element, sharing a common <tt>id</tt> root (<tt>post_title</tt>, in this
# case).
Generate an HTML id attribute value for the given name and
field combination

Return the value generated by the FormBuilder for the given
attribute name.



In the example above, the  element built by
the call to text_field_tag declares an
aria-describedby attribute referencing the 
element, sharing a common id root (post_title, in this
case).
Generate an HTML id attribute value for the given name and field combination Return the value generated by the FormBuilder for the given attribute name . In the example above the element built by the call to text_field_tag declares an aria - describedby attribute referencing the element sharing a common id root ( post_title in this case ) .
def field_id(object_name, method_name, *suffixes, index: nil, namespace: nil)
        if object_name.respond_to?(:model_name)
          object_name = object_name.model_name.singular
        end
        sanitized_object_name = object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").delete_suffix("_")
        sanitized_method_name = method_name.to_s.delete_suffix("?")
        [
          namespace,
          sanitized_object_name.presence,
          (index unless sanitized_object_name.empty?),
          sanitized_method_name,
          *suffixes,
        ].tap(&:compact!).join("_")
      end
def field_id ( object_name , method_name , * suffixes , index : nil , namespace : nil ) if object_name . respond_to? ( :model_name ) object_name = object_name . model_name . singular end sanitized_object_name = object_name . to_s . gsub ( / \] \[ |[^-a-zA-Z0-9:.] / , "_" ) . delete_suffix ( "_" ) sanitized_method_name = method_name . to_s . delete_suffix ( "?" ) [ namespace , sanitized_object_name . presence , ( index unless sanitized_object_name . empty? ) , sanitized_method_name , * suffixes , ] . tap ( & :compact! ) . join ( "_" ) end
Generate an HTML <tt>id</tt> attribute value for the given name and
field combination
Generate an HTML <tt > id< / tt > attribute value for the given name and field combination
object_name
<not_specific>
method_name
<not_specific>
suffixes
<not_specific>
index
<not_specific>
namespace
<not_specific>