gpt4 book ai didi

ruby-on-rails - 简单形式未定义方法路径

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

我是使用简单形式的新手。一开始我想制作一个简单的表格。

#country_controller
def edit
@country = Country.find(params[:id])
end

#edit.html.erb
<%= simple_form_for @country do |f| %>
<%= f.input :username %>
<%= f.input :password %>
<%= f.button :submit %>
<% end %>

但我收到此错误

undefined method `country_path' for #<#<Class:0x007fdb21098e00>:0x007fdb2108cad8>

我的路线

 management GET    /management(.:format)                              management/home#index
management_settings GET /management/settings(.:format) management/settings#list
management_country_index GET /management/country(.:format) management/country#index
edit_management_country GET /management/country/:id/edit(.:format) management/country#edit
management_country PATCH /management/country/:id(.:format) management/country#update
PUT /management/country/:id(.:format) management/country#update
DELETE /management/country/:id(.:format) management/country#destroy

最佳答案

因为您的路由稍微不标准,您需要将 url 显式传递给 simple_form_for

<%= simple_form_for @country, url: management_country_path(@country) do |f| %>

关于ruby-on-rails - 简单形式未定义方法路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34686843/

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