2011-05-18 25 views
0

這有希望很容易做到,但我無法在任何地方找到任何doco(可能是因爲我缺乏正確的搜索條件)。無論如何...限制導軌2.3命名路由到POST/GET

我想有兩個命名路線共享相同的路徑。兩者之間的顯着特點是一方會接受GET,另一方接受POST。

以下是我到目前爲止。我嘗試過使用a:方法arg和a:via param,但都沒有辦法。我也試過「:requirements => {:method =>:get}」。

map.show_current '/rounds/', :controller => :rounds, :action => :show, :method => :get 
map.create '/rounds/', :controller => :rounds, :action => :create, :via => [:post, :put] 

任何建議,將不勝感激,即使只是一個合適的搜索詞。

乾杯。

+0

我認爲:條件選項可能會做的伎倆... – 2011-05-18 00:57:48

+0

好,經常有它我已經發布了這個問題後很快算出來。 我正在尋找的選項是:conditions選項。所以我的路線如下所示: map.show_current'/ rounds /',:controller =>:rounds,:action =>:show,:conditions => {:method =>:get} map.create'/rounds /',:controller =>:rounds,:action =>:create:conditions => {:method =>:post} – 2011-05-18 01:04:20

回答

0

在看到我的問題沒有答案後,從我的評論中複製了此信息。

我正在尋找的選項是:conditions選項。所以,我的路線,如今這個樣子:

map.show_current '/rounds/', :controller => :rounds, :action => :show, :conditions => { :method => :get } 
map.create '/rounds/', :controller => :rounds, :action => :create :conditions => { :method => :post }