0

I am working on an application built with rails where I need to be able to generate urls with a "#" character at the beginning, like so:

user_path outputs "#/user/1"
dashboard_url outputs "http://mydomain.com/#/dashboard"

..and so on...

Any ideas what might be the best way to override the URL helper?

1 Answers1

1

I need to be able to generate urls with a "#" character at the beginning

Why? The server will never see anything after the fragment identifier. Such URLs won't be seen by Rails, and controllers won't be able to respond to them.

If you need to create a URL which ends with a fragment identifier, use :anchor.

link_to "Comment wall", profile_path(@profile, :anchor => "wall")
# => <a href="/profiles/1#wall">Comment wall</a>
ghoppe
  • 21,452
  • 3
  • 30
  • 21