【发布时间】:2018-09-23 15:00:13
【问题描述】:
我在 Rails 5 中使用 form_for 助手,使用路由命名空间功能并作为模型名称的别名。
我的路线:
edit_customer_profile GET /customer/profile/edit(.:format) customer/profiles#edit
customer_profile PATCH /customer/profile(.:format) customer/profiles#update
PUT /customer/profile(.:format) customer/profiles#update
我的看法:
... omit verbosity ...
<%= form_for [:customer, current_user], as: :profile do |f| %>
... omit verbosity ...
我的错误:
undefined method `customer_user_path' for #<#<Class:0x007f0f8d0ddce0>:0x00558c965b4a78>
手头有文档,表单助手必须使用customer_profile_path 而不是customer_user_path。
【问题讨论】:
-
<%= form_for [:customer, (current_user, as: :profile)] do |f| %>不确定这是否有效。 -
不,不工作
标签: ruby-on-rails forms routes helpers