我的问题是,当我直接在浏览器或任何链接中键入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时,“show”页面将显示相应的信息。我预计这也会发生在33,因为该项确实存在于表中,但显然不是。
以下是rake routes
/builds/:build_id/stories/:number/:id(.:format) stories#show
build_stories GET /builds/:build_id/stories(.:format)故事#index
POST /builds/:build_id/stories(.:format)故事#create
new_build_story GET /builds/:build_id/stories/new(.:format)story#new
edit_build_story GET /builds/:build_id/stories/:id/edit(.:format)story#edit
build_story GET /builds/:build_id/stories/:id(.:format)故事#show
PUT /builds/:build_id/stories/:id(.:format)故事#upup
DELETE /builds/:build_id/stories/:id(.:format)故事#stroy
build GET /builds(。:format)build #index
POST /builds(。:format)构建#create
new_build GET /builds/new(.:format)构建#new
edit_build GET /builds/:id/edit(.:format)build#edit
build GET /builds/:id(.:format)build#show
PUT /builds/:id(.:format)构建#update
DELETE /builds/:id(.:format)build#destroy
root / builds #index
join /join(.:format)build#join
离开/离开(.:format)建立#leave
完成/完成(。:format)构建#完成
restart /restart(.:format)build#restart
/auth/:provider/callback(.:format)sessions #create
auth_failure /auth/failure(.:format):controller#:action
signout /signout(.:format)sessions#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'