2010-05-21 58 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