Forum: Ruby on Rails [Rails 3.2.8] issue in regex scan

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2012-11-02 09:25
(Received via mailing list)
running a scan in irb is fine :

1.9.3p194 :001 > request_url =
"http://lvh.me::3000/en/backoffice/cms-admin/site/6...
 => "http://lvh.me::3000/en/backoffice/cms-admin/site/6...
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...
 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
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2012-11-02 09:34
(Received via mailing list)
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 topic is locked and can not be replied to.