2010-05-21 57 views
0

我想成立一​​個路線:Rails的路線:要求

 
atypes = [:culture, :personality, :communication] 
map.with_options(:path_prefix => ':atype', 
    :requirements => {:atype => atypes.include?(:atype)}) do |assessment| 
    ... 
end 

我一直沒能找到如何實現任何文件:一個驗證一個特定的參數包含在一個陣列的陣列上的要求這個。任何幫助,將不勝感激。

回答

0

:requirements選項需要正則表達式。像/(culture|presonality|communication)/。您也可以從陣列中構建一個:

atypes = [:culture, :personality, :communication] 
map.with_options(:path_prefix => ':atype', 
    :requirements => /(#{atypes.join('|')})/) do |assessment| 
    ... 
end