我通过脚手架创建了新模型,并在那里添加了新 Action - 快速。在routes.rb中,我添加了get“photos/quick”并创建了文件qucik.html.erb(它位于正确的 View 中 -目录)。
如果我将浏览器设置为localhost:3000/photos/quick,我将收到上述错误。 在我的 Controller 中,它看起来非常简单:
def quick
end
也在 View 中:
<div>this is template for quick action</div>
如何获得该错误消息?为什么是 run show 操作?
routes.rb:
FirstApp::Application.routes.draw do
resources :photos
get "photos/quick"
root :to => "photos#index"
end
最佳答案
更改路由以使用集合
并修复代码结构以正确使用 block :
FirstApp::Application.routes.draw do
resources :photos do
collection do
get "quick"
end
end
root :to => "photos#index"
end
关于ruby-on-rails-3 - Rails 3 - 找不到 ID=quick 的照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6888106/