我正在尝试使用此 url 访问我的 checkpoints#index 方法:
http://localhost:3000/lessons/introductions/checkpoints/
但我得到这个错误:
No route matches {:action=>"show", :controller=>"checkpoints", :lesson_id=>#<Checkpoint id: 1, checkpoint: "Definition of Monetary Policy", url: "http://www.youtube.com/watch?v=HX3wOWN9-sM", objective: "Define monetary policy", description: "Welcome to this series of lectures on monetary poli...", question: "What is the definition of monetary policy?", hint: "It is the deliberate manipulation of something OR s...", answer: "-", lesson_id: 8, created_at: "2012-06-29 07:21:47", updated_at: "2012-06-30 08:24:15", slug: "definition-of-monetary-policy">}
这不应该是这种情况,因为在我的“rake routes”中:
lesson_checkpoints GET /lessons/:lesson_id/checkpoints(.:format) checkpoints#index
POST /lessons/:lesson_id/checkpoints(.:format) checkpoints#create
new_lesson_checkpoint GET /lessons/:lesson_id/checkpoints/new(.:format) checkpoints#new
edit_lesson_checkpoint GET /lessons/:lesson_id/checkpoints/:id/edit(.:format) checkpoints#edit
lesson_checkpoint GET /lessons/:lesson_id/checkpoints/:id(.:format) checkpoints#show
PUT /lessons/:lesson_id/checkpoints/:id(.:format) checkpoints#update
DELETE /lessons/:lesson_id/checkpoints/:id(.:format) checkpoints#destroy`
它不会加载#index 操作而不是#show 操作吗?有谁知道这个错误的可能原因?
这就是我的 routes.rb 的样子:
resources :lessons do
resources :checkpoints
end
resources :lessons
resources :topics do
resources :lessons
end
#Devise Routes
devise_for :users
resources :subjects do
resources :topics
end