0

I had a doubt regarding RoR. I want to extract the path name from URL present in the Address bar.Suppose i have "http://localhost:3000/#toregister" in my address bar and i need only #toregister .So how can i fetch this path name to the controller page using only RoR.

rajat_474
  • 346
  • 1
  • 4
  • 15

3 Answers3

1

Use URI module

uri = URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
#=> #<URI::HTTP:0x00000000b14880 URL:http://foo.com/posts?id=30&limit=5#time=1305298413>
uri.fragment
#=> "time=1305298413"
0

Unfortunately - you can't do this. This is only client-side available. Check answer for more

Community
  • 1
  • 1
Paweł Dawczak
  • 9,519
  • 2
  • 24
  • 37
0

You can't get anchor's value on server side. But if you need to parse existing url string, you may use built-in URI module:

URI('http://localhost:3000/#toregister').fragment # returns 'toregister'
Alexaner Tipugin
  • 507
  • 4
  • 12