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:
- www.aboardoffices.com/coworking-in-delhi
- www.aboardoffices.com/coworking-in-mumbai
but not working in following cases:
- www.aboardoffices.com/coworking-in-sector7dwarka
- 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
Post a Comment