嗨我現在正在玩Rails並構建一個基本的應用程序。當我嘗試運行應用程序,我得到這個錯誤:在Rails 3.2中沒有方法錯誤
「未定義的方法`products_path」爲#<#:0x45c19f8>」
我的代碼如下......
配置:
Depot::Application.routes.draw do
resources :product
resources :test
end
控制器:
class ProductController < ApplicationController
def new
@product = Product.new
end
def show
@product = Product.find(params[:id])
end
end
查看:
<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 %>
我不明白爲什麼表單不會呈現並且收到錯誤消息。我錯過了什麼嗎?
謝謝任何幫助表示讚賞。
編輯添加配置文件。
顯示你的config/routes.rb文件 –