【发布时间】:2019-07-02 03:55:27
【问题描述】:
我正在使用 rails 5 和 form_with 助手。我的代码在使用 Form_for 时有效,但在 Form_with 时无效。 :as参数对Form_with无效吗?
查看
<%= form_with(model: @user_wizard , :as => :user_wizard, url: validate_step_wizard_path, local: true, builder: BsFormBuilder) do |f| %>
型号
def user_wizard_params
params.require(:user_wizard).permit( :name )
end
但是,每次我尝试提交表单时,参数都会提交:
{"utf8"=>"✓",
"authenticity_token"=>"LvRDsdfsdfsd3V0l4NLg14q2JWBdwkDPqUIu2l7SXDiioCtvMwW6Bv3ss/LPSS9+bdxiPIzjg==",
"current_step"=>"step1",
"wizard_user_step1"=>
{"name"=>"Name"}
}
我一直在关注这个..https://medium.com/@nicolasblanco/developing-a-wizard-or-multi-steps-forms-in-rails-d2f3b7c692ce
但是,我的代码使用 Form_with,而他们使用 Form_for。不知道有什么区别。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-5 form-for