routes - Regex in Rails Routing -


i want create routes value accepted, have created 1

get '/coworking-in-:coworking_place', to: 'home#coworking', constraints: { :coworking_place => /[a-z]*[a-z]*/ }

it working fine following cases:

  1. www.aboardoffices.com/coworking-in-delhi
  2. www.aboardoffices.com/coworking-in-mumbai

but not working in following cases:

  1. www.aboardoffices.com/coworking-in-sector7dwarka
  2. www.aboardoffices.com/coworking-in-dlfphase1gurgaon

i want create route can accept parameters in :coworking_place

your regular expression /[a-z]*[a-z]*/ doesn't capture groups. see - http://rubular.com/r/larelzp1qu

you need /[a-za-z0-9-]+/. whitelists upper-case, lowercase characters, numbers, , -. check result - http://rubular.com/r/nickqdqijl


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -