gpt4 book ai didi

ruby-on-rails-5 - 导轨 5 : form_for vs form_with

转载 作者:行者123 更新时间:2023-12-04 07:04:26 25 4
gpt4 key购买 nike

Rails 5 引入了新的表单辅助方法 form_with .

form_for有什么区别什么时候使用更合适?

最佳答案

这真的是为 Rails 5.1 做准备,其中只有 form_with应该使用。它旨在替代这两种方法 form_forform_tag .

form_for and form_tag in Rails were very similar, both allowed you to create a form tag but the first one uses model’s attributes to build create or update form, while the second one simply creates an HTML form tag with the passed URL as action.

关于ruby-on-rails-5 - 导轨 5 : form_for vs form_with,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43868976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com