在rails中,是否使用表单助手? [英] In rails, whether to use form helpers or not to?

查看:77
本文介绍了在rails中,是否使用表单助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Rails中,建议使用表单助手吗?在内部,一切都归结为纯HTML,那么为什么不直接编写HTML?显然,编写直接html的性能将比使用辅助程序更好.是在使用表单帮助程序(例如约定)还是Rails开发人员必须遵循的形式?

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 in writing direct html than using helpers. Is using form helpers like a convention or something that rails developers must follow?

推荐答案

定义性能.您的性能或应用程序?假设您在视图中分散了相同的rhtml代码段.假设您在数千个地方都拥有它.也许您甚至没有在所有地方都完全获得相同的结果.现在,您的客户想要更改此设置(可能是不同的显示顺序或类似的顺序).在所有视图中都需要花费一些时间,对吗?而且很可能您不会在第一时间就做对.实际上,很可能您会在多年未更改的地方不断收到错误报告.

Define performance. Your performance or the applications? Say you have the same rhtml snippet spread out across your views. Say you have it in thousands of places. Maybe you even haven't gotten it exactly the same in all places. Now your customer wants to change this (maybe different order of presentation or some such). It'll take you a while to do this in all the views, right? And chances are you won't get it right the first time. Chances are in fact that you'll keep getting bug reports for years to come on places you've missed to change.

客户最终将为获得的性能"付出高昂的代价.可能需要数百个工作小时.如果您原则上避免使用DRY原则,则可能有成千上万.考虑一下她可以在那些工作时间内购买的所有服务器和所有RAM.如果她将所有这些花费在硬件上,那么她的应用程序运行速度可能会快上百倍.想一想您可能会遇到的所有有趣的事情,而不是费力地去更改html代码段.

The customer will end up paying a lot for that gained "performance". Maybe hundreds of working hours. Maybe tens of thousands if you avoid the DRY principle on principle. Think of all the servers and all the RAM she could buy for those work hours instead. If she spent it all on hardware her application might run hundred-folds faster. Think of all the fun things you could be working with instead of monkeying around changing html snippets.

这篇关于在rails中,是否使用表单助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆