Reputation: 924
Hi I'm playing with Rails at the moment and building a basic app. When I try to run the app I get this error:
"undefined method `products_path' for #<#:0x45c19f8>"
My code is as follows...
Config:
Depot::Application.routes.draw do
resources :product
resources :test
end
Controller:
class ProductController < ApplicationController
def new
@product = Product.new
end
def show
@product = Product.find(params[:id])
end
end
View:
<h1>Page to add new products</h1>
<%= form_for(@product) do |f| %>
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.label :description %>
<%= f.text_field :description %>
<%= f.label :price %>
<%= f.text_field :price %>
<%= f.submit "Create new product" %>
<% end %>
I don't understand why the form won't render and I receive the error message. Am I missing something?
Thanks any help appreciated.
Edited to add config file.
Upvotes: 0
Views: 83
Reputation: 5111
Just add the following line in config/routes.rb
resources :products
Upvotes: 1