大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – Rails 3 |路由:现在如何重命名资源标题?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在Rails 2.3.5它是
@H_662_2@map.resources:menu_items,as as => :菜单,:path_names => {:new => ‘add’}现在在Rails 3.0.3中,我可以使用这段巨大的代码段来处理它
resources :menu_items,:path_names => { :new => 'add' } match 'menu/' => 'menu_items#index',:as => :menu match 'menu/add' => 'menu_items#new',:as => :new_menu match 'menu/:id' => 'menu_items#show',:as => :show_menu match 'menu/:id/edit' => 'menu_items#edit',:as => :edit_menu
但是由于代码量庞大,因此看起来不正确.
好像就像第二个Rails的map.some_name一样.
任何帮助/建议/指南? (谢谢)
resources :menu,:controller => "menu_items",:path_names => { :new => "add" }
输出与你以后的输出非常接近:
@H_208_8@menu_index GET /menu(.:format) {:controller=>"menu_items",:action=>"index"} POST /menu(.:format) {:controller=>"menu_items",:action=>"create"} new_menu GET /menu/add(.:format) {:controller=>"menu_items",:action=>"new"} edit_menu GET /menu/:id/edit(.:format) {:controller=>"menu_items",:action=>"edit"} menu GET /menu/:id(.:format) {:controller=>"menu_items",:action=>"show"} PUT /menu/:id(.:format) {:controller=>"menu_items",:action=>"update"} deletE /menu/:id(.:format) {:controller=>"menu_items",:action=>"destroy"}以上是大佬教程为你收集整理的ruby-on-rails – Rails 3 |路由:现在如何重命名资源标题?全部内容,希望文章能够帮你解决ruby-on-rails – Rails 3 |路由:现在如何重命名资源标题?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。