So I did find similar questions but could not quite find a good answer, so here's my question
I keep getting this method error when trying to go into localhost:3000/clients/1/precios/new (the error comes from the _form.html.erb)
First of all 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
And this is the error I keep getting
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>
And this is my _form.html.erb
<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>
What is it that I need to change in the form?