[Rails 3.2.8] issue in regex scan

20 views
Skip to first unread message

Erwin

unread,
Nov 2, 2012, 4:24:43 AM11/2/12
to rubyonra...@googlegroups.com
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 :

 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


Erwin

unread,
Nov 2, 2012, 4:33:21 AM11/2/12
to rubyonra...@googlegroups.com
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 :
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-ad  'sites' min/site/6/pages"  
Reply all
Reply to author
Forward
0 new messages