我剛剛升級到Rails 3,並決定採用虛擬/沙箱應用程序進行旋轉。奇怪的是我似乎無法獲得任何路線上班!爲什麼這個基本的Rails 3路線不工作?
這裏是我的問題:
[[email protected]:Dev]$rails new TestApp
create
create README
create Rakefile
...
[[email protected]:Dev]$cd TestApp/
[[email protected]:TestApp]$rails g scaffold widget name:text
invoke active_record
create db/migrate/20101020115518_create_widgets.rb
create app/models/widget.rb
...
[[email protected]:TestApp]$rake db:migrate
(in /Users/cobychapple/Dev/TestApp)
== CreateWidgets: migrating ==================================================
-- create_table(:widgets)
-> 0.0015s
== CreateWidgets: migrated (0.0016s) =========================================
[[email protected]:TestApp]$rake routes
(in /Users/cobychapple/Dev/TestApp)
widgets GET /widgets(.:format) {:action=>"index", :controller=>"widgets"}
widgets POST /widgets(.:format) {:action=>"create", :controller=>"widgets"}
new_widget GET /widgets/new(.:format) {:action=>"new", :controller=>"widgets"}
edit_widget GET /widgets/:id/edit(.:format) {:action=>"edit", :controller=>"widgets"}
widget GET /widgets/:id(.:format) {:action=>"show", :controller=>"widgets"}
widget PUT /widgets/:id(.:format) {:action=>"update", :controller=>"widgets"}
widget DELETE /widgets/:id(.:format) {:action=>"destroy", :controller=>"widgets"}
[[email protected]:TestApp]$rails s -d
=> Booting WEBrick
=> Rails 3.0.1 application starting in development on http://0.0.0.0:3000
[[email protected]:TestApp]$
所以,現在我頭就到我的瀏覽器,並訪問http://localhost:3000/widgets
Rails的說: 路由錯誤:沒有路由匹配 「/小工具」
我不要理解rake路由如何顯示路由存在,然後服務器就不會匹配它。我已經搜索了一大堆,似乎有一些人在軌道3中的路由問題,但沒有一個顯然是我得到的基本。我肯定我在路上錯過了一些小小的東西,但我不能爲了我的生活而弄明白!有什麼建議麼?
我的routes.rb文件只是什麼腳手架生成+文檔註釋:
TestApp::Application.routes.draw do
resources :widgets
# The priority is based upon order of creation:
# skip the rest of the comments...
end
HAV你的文件app /控制器/ widgets_controller.rb? – shingara 2010-10-20 12:18:58
我做了和你一樣的步驟,它的工作沒有問題。奇怪... – Matt 2010-10-20 13:45:17
是... app/controllers/widgets_controller.rb存在並由腳手架腳本生成。謝謝你的檢查! – Coby 2010-10-20 21:35:29