I am working on an ap开发者_如何学编程plication 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?
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>
精彩评论