我想设置一个路由:验证特定参数的数组的要求是否包含在数组中:
atypes = [:culture, :personality, :communication] map.with_options(:path_prefix => ':atype', :requirements => {:atype => atypes.include?(:atype)}) do |assessment| ... end
我无法找到有关如何完成此任务的任何文档。任何帮助将不胜感激。
答案 0 :(得分:0)
:requirements
选项需要正则表达式。像/(culture|presonality|communication)/
这样的东西。您还可以从数组中构造一个:
atypes = [:culture, :personality, :communication]
map.with_options(:path_prefix => ':atype',
:requirements => /(#{atypes.join('|')})/ ) do |assessment|
...
end