2010-06-23 31 views
5

我似乎不能在軌道3在Rails 3中路由:帶選項的地圖?

作爲一個具體的例子來找到映射文檔航線的選項,我需要翻譯

map.with_options :controller => 'users' do |signup| 
    signup.signup '/signup', 
     :action => 'landing', 
     :conditions => { :method => :get } 
    signup.premium '/signup/premium', 
     :action => 'new', 
     :level => 'premium', 
     :conditions => { :method => :get }  
    signup.premium '/signup/premium', 
     :action => 'create', 
     :level => 'premium', 
     :conditions => { :method => :post } 
    signup.free '/signup/free', 
     :action => 'new', 
     :level => 'free', 
     :conditions => { :method => :get }  
    signup.free '/signup/free', 
     :action => 'create', 
     :level => 'free', 
     :conditions => { :method => :post }  
    end 

進了Rails3中正確的語法。我相信這一點很簡單,我忽略了,但任何幫助或鏈接到文章將是奇妙的。

回答

4
scope '/signup' do 
    match '/signup' => "users#landing", :as => :signup 
    get '/:level' => 'users#new', :as => :signup_new 
    post '/:level' => 'users#create', :as => :signup_create 
end 

這具體是什麼我一直在尋找,它是在第一不清楚(我),這是選項如何翻譯。

+0

我想補充一點,我需要爲這些限制添加限制,只允許免費和溢價作爲關卡的選項,但這相對來說不重要。 – 2010-07-18 00:09:19

+0

謝謝!一直在尋找這個 – stephenmurdoch 2010-09-02 06:35:49

0

http://guides.rails.info/index.html(邊軌文檔),看你如何翻譯你的Rails 2.x的路線

+1

謝謝,但我已經讀過所有這些,我希望有一個具體的例子。 – 2010-07-18 00:08:13

0
scope '/signup' do 
with_options :controller => :users do |signup| 
    signup.match '/signup', :action => :landing 
    signup.get '/:level', :action => :new, :as => :signup_new 
     # or just signup.get '/:level/new', :action => :new 
    signup.post '/:level', :action => :create, :as => :signup_create 
end 
end