1
我是Ruby和Ruby on Rails的新手,我在Max OSX Lion上使用Ruby 1.9.2和Rails 3.2.5,并正在通过“使用Rails进行敏捷Web开发(第4版)”一书。当路线存在时,为什么我会得到一个无路线匹配[GET]“/ products”?
我已经使用在第6章概述如下命令创建自己的样品储存罐的应用:
- 轨新车厂
- 轨产生支架产品名称:字符串描述:文本图片网址:串价格:小数
- 耙分贝:迁移
- 轨服务器
当我点Safari浏览器的“http://本地主机:3000 /产品”我碰到下面的动作控制器:捕获到异常错误信息,而不是看到一个产品列表页:
Routing Error
No route matches [GET] "/products"
Try running rake routes for more information on available routes.
运行‘在终端耙路线’给我:
products GET /products(.:format) products#index
POST /products(.:format) products#create
new_product GET /products/new(.:format) products#new
edit_product GET /products/:id/edit(.:format) products#edit
product GET /products/:id(.:format) products#show
PUT /products/:id(.:format) products#update
DELETE /products/:id(.:format) products#destroy
以下行被自动添加到routes.rb。
resources: product
products_controller.rb中还有一个索引方法。
class ProductsController < ApplicationController
# GET /products
# GET /products.json
def index
@products = Product.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @products }
end
end
翻遍了书的errata和forums的不转了任何可能的解决方案。
在此先感谢。