大佬教程收集整理的这篇文章主要介绍了表单中未识别方法的错误 - Ruby on rails,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我确实找到了类似的问题,但找不到很好的答案,所以这是我的问题
尝试进入 localhost:3000/clIEnts/1/precios/new 时,我不断收到此方法错误(错误来自 _form.HTMl.erb)
首先routes.rb
Rails.application.routes.draw do
#resources :precios
#resources :catalogos
resources :clIEnts do
#resources :catalogs,shallow: true
resources :remissions,shallow: true
resources :catalogos
resources :precios
end
resources :catalogs do
resources :products,shallow: true do
resources :prices,shallow: true
end
end
devise_for :users
devise_scope :user do
get '/users/sign_out ' => 'devise/sessions#destroy'
end
# For details on the DSL available within this file,see https://guIDes.rubyonrails.org/routIng.HTML
root 'home#index',as: 'home'
get 'new' => 'clIEnts#new',as: 'alta_clIEnte'
get 'clIEnts#index' => 'clIEnts#index',as: 'Lista_clIEntes'
get 'remissions#index' => 'remissions#new',as: 'nueva_remision'
end
这是我不断收到的错误
undefined method `precios_path' for #<#<Class:0x000000000d1f7018>:0x000000000a18fc90>
DID you mean? price_path
Extracted source (around line #2):
<div class="alta-form-container">
<%= form_with(model: precio,local: truE) do |form| %> (Error in this linE)
<% if precio.errors.any? %>
<div ID="error_explanation">
<h2><%= pluralize(precio.errors.count,"error") %> prohibited this precio from being saved:</h2>
<div class="alta-form-container">
<%= form_with(model: precio,local: truE) do |form| %>
<% if precio.errors.any? %>
<div ID="error_explanation">
<h2><%= pluralize(precio.errors.count,"error") %> prohibited this precio from being saved:</h2>
<ul>
<% precio.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="fIEld">
<%= form.label :precio %>
<%= form.number_fIEld :precio %>
</div>
<div class="fIEld">
<%= form.label :clIEnt_ID %>
<%= form.text_fIEld :clIEnt_ID %>
</div>
<div class="fIEld">
<%= form.label :catalogo_ID %>
<%= form.text_fIEld :catalogo_ID %>
</div>
<div class="actions">
<%= form.submit %>
</div>
<% end %>
</div>
我需要在表单中更改什么?
你在路由中有以下代码
resources :clients do
resources :precios
end
因此您需要 clients
和 precios
对象,请尝试遵循
<%= form_with(model: [client,precio],local: truE) do |form| %>
以上是大佬教程为你收集整理的表单中未识别方法的错误 - Ruby on rails全部内容,希望文章能够帮你解决表单中未识别方法的错误 - Ruby on rails所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。