gpt4 book ai didi

ruby-on-rails - Rails路由直接索引操作以显示操作

转载 作者:行者123 更新时间:2023-12-04 13:12:27 25 4
gpt4 key购买 nike

因此,我为一个练习模型创建了一些rspec_scaffold并将“map.resource:exercises”添加到路由文件中,当“/exercises” URL呈现show Action 时,我感到很惊讶。有没有搞错?为什么不呈现索引 Action ?

耙路

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"}

最佳答案

使用单词resource时,您设置了一个单数路径。改用它。

map.resources :exercises

关于ruby-on-rails - Rails路由直接索引操作以显示操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2677027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com