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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
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.


Reply via email to