Estou tentando fazer um form_for
para cadastrar um equipamento, mas sempre que vai para a view de criar o equipamento obtenho erro.
Model de equipment:
class Equipment < ApplicationRecord
validates :name, presence: true
has_many :orderequipments, dependent: :destroy
has_many :orders, through: :orderequipments
end
Controller:
def new
@equipment = Equipment.new
end
def create
@equipment = Equipment.new(equipment_params)
if @equipment.save
redirect_to equipments_path
else
render :new
end
end
def equipment_params
params.require(:equipment).permit(:name)
end
E a view de new:
<div class="container">
<div class="container-form">
<%= simple_form_for(@equipment) do |f| %>
<div class="product-new text-center">Cadastro de Equipamento:</div>
<div class="form-inputs">
<%= f.input :name, label: "Equipamento" %>
</div>
<div class="form-actions text-center">
<%= f.button :submit, "Enviar" %>
</div>
<% end %>
</div>
</div>
Mas quando vai pra view de new sempre me aparece este erro:
NoMethodError in Equipments#new
Showing /home/eduardo/code/eduardototi/vegoorapp/app/views/equipments/new.html.erb where line #3 raised:
undefined method `equipment_index_path' for #<#<Class:0x00007fac0c0d4480>:0x00007fac0c0e2b98>
Did you mean? equipment_path
Extracted source (around line #3):
1 <div class="container">
2 <div class="container-form">
3 <%= simple_form_for(@equipment) do |f| %>
4 <div class="product-new text-center">Cadastro de Equipamento:</div>
5 <div class="form-inputs">
6 <%= f.input :name, label: "Equipamento" %>
Rails.root: /home/eduardo/code/eduardototi/vegoorapp
Application Trace | Framework Trace | Full Trace
app/views/equipments/new.html.erb:3
Alguem saberia me explicar porque este erro esta acontecendo?