GET的路由错误]“/ firstapp”

时间:2011-09-23 06:41:36

标签: ruby-on-rails routing ruby-on-rails-3.1 rails-routing

我试图在安装后编写我的第一个程序,但是我收到了如下错误:

Routing Error
No route matches [GET] "/firstapp"

我试图更改我的config/routes.rb文件但没有改变。这是我的config/routes.rb

Firstapp::Application.routes.draw do
  resources :apptables

  # The priority is based upon order of creation:
  # first created -> highest priority.

  # continues with default `config/routes.rb` explanations...
end    

如何配置config/routes.rb以使其正常运行?

1 个答案:

答案 0 :(得分:3)

只是说resources :apptables sets up the standard seven routes

GET    /apptables
GET    /apptables/new
POST   /apptables
GET    /apptables/:id
GET    /apptables/:id/edit
PUT    /apptables/:id
DELETE /apptables/:id

该列表中没有/firstapp,因此该路由不起作用。如果您希望/firstapp上的GET工作,那么您可以手动设置该路线:

match '/firstapp' => 'firstapp#some_method', :via => :get

这会将GET /firstapp路由到FirstappController#some_method