Search code examples
ruby-on-railsroutesrails-routing

Rails routes with specific character


I have bellow url request type, that contain # character

http://localhost:3000#user-name

I want to match it to HomeController#show_user, how to write the routes?


Solution

  • From Uniform Resource Locators (URL)

    The character "#" is unsafe and should always be encoded because it is used in World Wide Web and in other systems to delimit a URL from a fragment/anchor identifier that might follow it.

    You can't use # symbol in your url because it's a reserved character.

    You might have seen the usage of symbol like this

    https://www.google.com/search?q=hello+world#brs
    

    But this symbol used here as fragment delimeter.