I’m pretty new to Rails (8.0.1 at the moment), so please forgive a naive question.
What is the best way to get the details for a Rails function call?
For example, if I look up form.text_field in the API Docs I get this:
text_field(method, options = {})Link
Wraps ActionView::Helpers::FormHelper#text_field for form builders:
<%= form_with model: @user do |f| %>
<%= f.text_field :name %>
<% end %>
Please refer to the documentation of the base helper for details.
Source: on GitHub
What I want to find is all the available options. I have run across :name and method: in example code, but it took me quite a while to stumble across placeholder: and class:.
Those are HTML options, not Rails per se. You can append them to any Rails view helper that generates an HTML tag by using Ruby hash syntax, e.g., placeholder: 'Enter name here', class: :some_css_class_name.
In this case options are added as attributes - in others the options can be something else
From the docs of text_field
Additional options on the input tag can be passed as a hash with options . These options will be tagged onto the HTML as an HTML element attribute as in the example shown.