Reputation: 1497
<%= f.label :password %>
<%= f.password_field :password, class: 'form-control' %>
The method signature of password_field is:
def password_field(object_name, method, options = {})
Upvotes: 1
Views: 32
Reputation: 44380
In the "... f.password_field :password..." line, are two arguments getting passed into password_field? So it's the same as "f.password_field(:password, class: 'form-control')?
f.password_field :password, class: 'form-control'
- here you pass two arguments to f.password_field function
According to the method signature of pw_field, ":password" should be an object. However, it's a symbol which as I understand is more like a string than a pointer. How does inputting this as an object make sense?
It is not an object, is object_name
object name
Why is the "class: 'form-control'" argument a method? It doesn't seem like a method to me, but it's not a hash so I assume it should not be the "options" in the method signature..
class: 'form-control'
it is not a method, is an argument, also is a hash.
How does "class: 'form-control'" get evaluated into HTML (and what resource tells me how that happens)?
With FormBuilder
. It's generate the html under the hood and use "class: 'form-control'"
argument to set the class.
Also with object_name, is the object name automatically a pointer to an object?
object_name
it is a name of the attribute of the model which you're using. password_field
function do not know, the form builder know.
I suggest you to read Ruby Basic
Upvotes: 1