Rails Routing Conditional with multiple value options -
I have a railway route that is based on two conditions, that domain and subdomain are a specific value The problem is that the subdomain There are several possible values for working, but I can not give them as an array or a hash. ; {: Domain = & gt; Ap conifig ['base_domain'] ,: subdomain => 'Www' .. 'www3'}) Sign up | Sign up | Signup.plans '/ signup' ,: Controller = & gt; 'Account',: Action = & gt; 'Plan' ... [Small] ... end
The above examples are www, www1, www2 and amp; Although W33 is a value for subdomains, it does not really solve my needs, I need to be able to accept the value of '' (nothing), 'www' and 'www2', so I Try some of the extension:
map.with_options (: conditions => {: domain => ap conifig ['base_domain'],: subdomain => ['' , 'Www', 'www2']}).
How will you install it in ActiveRecord, but it does not appear to be the same for routes.
Does anyone know now that I can specify three values which are not sequential?
If you can provide it as a regular expression, you can use it one As a condition, converting the array into regular expressions is quite easy:
: subdomain => Regexp.new (% w [www www3] .collect {| p | Regexp.escape (p)} .join ('|'))
Since you have only one Simple pattern, why not express it?
: subdomain => / Www \ d * /
It is important to keep in mind that the regular expression used by the routes, such as ^
or $
But they should be fully valid, and partial matches are ignored.
Comments
Post a Comment