以下是我在Rails 2中的一些路由,并希望升级到Rails 3:
map.callback "/auth/:provider/callback", :controller => "authorizations", :action => "create" #omniauth
map.failure "/auth/failure", :controller => "authorizations", :action => "failure" #omniauth
map.signup 'signup', :controller => 'users', :action => 'new'
map.signin 'signin', :controller => 'user_sessions', :action => 'new'
map.signout 'signout', :controller => 'user_sessions', :action => 'destroy'
答案 0 :(得分:5)
match "/auth/:provider/callback" => "authorizations#create", :as => :callback
match "/auth/failure" => "authorizations#failure", :as => :failure
match "signup" => "users#new", :as => :signup
match "signin" => "user_sessions#new", :as => :signin
match "signout" => "user_sessions#destroy", :as => :signout
这应该让你去。
我肯定会查看apneadiving
提到的截屏视频以及Rails' take on routes。
答案 1 :(得分:5)
查看https://github.com/rails/rails_upgrade及其rake rails:upgrade:routes
上的rails_upgrade插件。
script/plugin install git://github.com/rails/rails_upgrade.git
rake rails:upgrade:routes
这将获取当前路由文件并使用Rails 3语法重写它。在通过其他一些答案阅读文档后,复制控制台输出并查找任何可能的优化。
答案 2 :(得分:3)
答案 3 :(得分:2)
您还可以在Rails Routing from the Outside In找到很多很棒的信息。