views:

21

answers:

1

I want to set a route :requirements on an array that verifies a particular parameter is included in an array:

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

I haven't been able to find any documentation on how to accomplish this. Any help would be appreciated.

A: 

:requirements option expects regular expression. Something like /(culture|presonality|communication)/. You can also construct one from the array:

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