1

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

路由.rb

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  

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

4

1 回答 1

0

我有

map.resources :tv_summaries  
map.resources :tv_shows  

我的 route.rb 文件中的所有内容都在评论这两行解决了问题。

于 2012-10-25T18:19:14.257 回答