In rails, whether to use form helpers or not to?

前端 未结 5 980
天命终不由人
天命终不由人 2021-01-05 12:18

In rails, is it recommended to use form helpers? Internally, everything boils down to plain html then why not write the html directly? Performance will obviously be better i

5条回答
  •  独厮守ぢ
    2021-01-05 13:14

    I think that form helpers is a reflection of the DRY (don't repeat yourself) principle. Rather than writing the same code over to do similar tasks, creating a form helper that allows you to reuse that code is the way to go. That way if you need to make a change or fix, you only need to do it in one place. It also helps to make your code more compact and readable to abstract a complex action into a form helper. The same is true of partial views, though partial views tend to encapsulate more complex mark up than a form helper.

提交回复
热议问题