[Rails 3.2.8] issue in regex scan

running a scan in irb is fine :

1.9.3p194 :001 > request_url =
http://lvh.me::3000/en/backoffice/cms-admin/site/6/pages”
=> “http://lvh.me::3000/en/backoffice/cms-admin/site/6/pages”
request_url.scan(/^([\S]+)(backoffice/cms-admin/site/)(\d+)(/pages)$/)[0][2]
=> “6”

however running it in my controller doesn’t gives any result :

(rdb:1) request.url
http://lvh.me:3000/en/backoffice/cms-admin/sites/6/pages
site_id =
request.url.scan(/^([\S]+)(backoffice/cms-admin/site/)(\d+)(/pages)$/)[0][2]
NoMethodError Exception: undefined method `[]’ for nil:NilClass

(rdb:1)
request.url.scan(/^([\S]+)(backoffice/cms-admin/site/)(\d+)(/pages)$/)
[]

empty result

the url is the same, the regex also … what’s wrong with performing the
scan in a Rails app ?

thanks for feedback

sorry … found the ‘bug’ … typing error should be ‘sites’ in the
regex

sacnning fine now …

Le vendredi 2 novembre 2012 09:24:43 UTC+1, Erwin a crit :

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs