- Most magical form helper in rails
- form_for is a ruby method into which a ruby object is passed
- form_for yields a form builder object (typically
f
) - methods to create form controls are called on
f
, the form builder element - when the object is passed as a form_for parameter, it creates corresponding inputs with each of the attributes
- if i had
form_for(@cat)
, then the form field params would look likecat[name]
,cat[color]
, etc
- if i had
- in keeping with Rails convention regarding RESTful routes, there should be a resource declared for each model object (eg,
resources :cats
)