所以我为一个练习模型创建了一些rspec_scaffold,并将“map.resource:exercises”添加到我的路径文件中,当“/ exercise”url呈现show动作时,我感到很惊讶。有没有搞错?为什么不渲染索引操作?
rake routes
new_exercises GET /exercises/new(.:format) {:controller=>"exercises", :action=>"new"}
edit_exercises GET /exercises/edit(.:format) {:controller=>"exercises", :action=>"edit"}
exercises GET /exercises(.:format) {:controller=>"exercises", :action=>"show"}
PUT /exercises(.:format) {:controller=>"exercises", :action=>"update"}
DELETE /exercises(.:format) {:controller=>"exercises", :action=>"destroy"}
POST /exercises(.:format) {:controller=>"exercises", :action=>"create"}
答案 0 :(得分:18)
使用单词resource
时设置单一路线。请改用它。
map.resources :exercises