Choylton B. Higginbottom
Choylton B. Higginbottom

Reputation: 2304

Whats is the significance of "_tag" on Rails form helpers?

Rails forms seem to accept helpers like email_field_tag but also email_field. What is the significance of _tag?

Upvotes: 3

Views: 120

Answers (1)

TK-421
TK-421

Reputation: 10763

Tag helpers aren't model-bound, as explained here:

http://guides.rubyonrails.org/form_helpers.html#dealing-with-model-objects-model-object-helpers

"A particularly common task for a form is editing or creating a model object. While the *_tag helpers can certainly be used for this task they are somewhat verbose as for each tag you would have to ensure the correct parameter name is used and set the default value of the input appropriately. Rails provides helpers tailored to this task. These helpers lack the _tag suffix, for example text_field, text_area."

Upvotes: 1

Related Questions