gpt4 book ai didi

ruby - Rails 2.3.5 嵌套路由替换/删除路由

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

在 Rails 2.3.5 中。怎么可以从

rake routes
(in /home/railsApp)
tv_shows GET /tv_shows(.:format) {:controller=>"tv_shows", :action=>"index"}
POST /tv_shows(.:format) {:controller=>"tv_shows", :action=>"create"}
new_tv_show GET /tv_shows/new(.:format) {:controller=>"tv_shows", :action=>"new"}
edit_tv_show GET /tv_shows/:id/edit(.:format) {:controller=>"tv_shows", :action=>"edit"}
tv_show GET /tv_shows/:id(.:format) {:controller=>"tv_shows", :action=>"show"}
PUT /tv_shows/:id(.:format) {:controller=>"tv_shows", :action=>"update"}
DELETE /tv_shows/:id(.:format) {:controller=>"tv_shows", :action=>"destroy"}


rake routes
(in /home/railsApp)
tv_shows GET /tv/shows(.:format) {:controller=>"tv/shows", :action=>"index"}
POST /tv/shows(.:format) {:controller=>"tv/shows", :action=>"create"}
new_tv_show GET /tv/shows/new(.:format) {:controller=>"tv/shows", :action=>"new"}
edit_tv_show GET /tv/shows/:id/edit(.:format) {:controller=>"tv/shows", :action=>"edit"}
tv_show GET /tv/shows/:id(.:format) {:controller=>"tv/shows", :action=>"show"}
PUT /tv/shows/:id(.:format) {:controller=>"tv/shows", :action=>"update"}
DELETE /tv/shows/:id(.:format) {:controller=>"tv/shows", :action=>"destroy"}

路由文件
map.namespace :tv do |tv|
['shows', 'summaries'].each do |controller|
tv.connect "#{controller}/:action",
:controller => controller,
:conditions => { :method => :get },
:requirements => { :action => /auto_complete_for_\S+/ }
end

tv.resources :summaries
tv.resources :shows

结尾

在数据库中,该表名为 tv_shows。但是在我的应用程序中,我有一个文件夹 tv,其中显示了一个文件。
App = ruby 1.8.6 and Rails 2.3.5  

你能给我指出好的嵌套路由,命名空间教程。

最佳答案

我有

map.resources :tv_summaries  
map.resources :tv_shows

我的 route.rb 文件中所有最重要的注释这两行都解决了这个问题。

关于ruby - Rails 2.3.5 嵌套路由替换/删除路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13035394/

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