Friday, November 2, 2012

[Rails] [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


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Tk4hhR7VV6QJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate