我的问题是,当我http://localhost:3000/builds/1/stories/33
直接在浏览器中或从任何链接中输入时,我会收到此错误。
没有路线匹配 {:action=>"show", :controller=>"stories", :build_id=>1, :id=>nil}
这似乎只是当我尝试访问表中的最后一项时才会出现的问题,例如,如果我输入 34 作为 :id ,我会得到这个响应。
找不到 id=34 的故事 [WHERE "stories"."build_id" = 1]
当 :id 不存在时,这通常是预期的。因此,我不确定为什么错误只发生在表中的最后一项。任何帮助将不胜感激,因为这非常令人沮丧。我也使用 SQLite3 作为我的数据库。当我键入 32 时,“显示”页面会显示适当的信息。我预计这也会发生在 33 上,因为该项目确实存在于表中,但显然不存在。
这是从rake routes
/builds/:build_id/stories/:number/:id(.:format) stories#show
build_stories GET /builds/:build_id/stories(.:format) stories#index
POST /builds/:build_id/stories(.:format) stories#create
new_build_story GET /builds/:build_id/stories/new(.:format) stories #new
edit_build_story GET /builds/:build_id/stories/:id/edit(.:format) stories#edit
build_story GET /builds/:build_id/stories/:id(.:format) stories#show
PUT /builds/:build_id /stories/:id(.:format) stories#update
DELETE /builds/:build_id/stories/:id(.:format) stories#destroy
builds GET /builds(.:format) builds#index
POST /builds(.:format) builds#create
new_build GET /builds/new(.:format) builds#new
edit_build GET /builds/:id/edit(.:format) builds#edit
build GET /builds/:id( .:format) builds#show
PUT /builds/:id(.:format) builds#update
DELETE /builds/:id(.:format) builds#destroy
root / builds#index
join /join(.:format) builds#加入
离开 /leave(.:format) builds#leave
complete /complete(.:format) builds#complete
restart /restart(.:format) builds#restart
/auth/:provider/callback(.:format) sessions#create
auth_failure / auth/failure(.:format) :controller#:action
注销 /signout(.:format) 会话#destroy
这是我的 routes.rb
Sapphire::Application.routes.draw do
match '/builds/:build_id/stories/:number/:id', :to => 'stories#show'
resources :builds do
resources :stories
end
root :to => "builds#index"
match '/join', :to => 'builds#join'
match '/leave', :to => 'builds#leave'
match '/complete', :to => 'builds#complete'
match '/restart', :to => 'builds#restart'
match 'auth/:provider/callback', to: 'sessions#create'
match 'auth/failure', to: redirect('/')
match 'signout', to: 'sessions#destroy', as: 'signout'