I need to have path like "#privacy" for tab plugin. Link must contain only anchor. When I use link_to 'Privacy', :anchor => 'privacy'
Rails generate /privacy#privacy
- link, that contains full path and anchor.
How can I told Rails to generate url without path (only anchor)?
Thanks.
Solved: link_to 'Privacy', '#privacy'
The following will create a link the way you want -
link_to "my-privacy", "#privacy"
In most browsers, the path of the current page will be prefixed, but if you check the source of the page, the following html will be seen -
<a href="#privacy">my-privacy</a>
This will most probably serve your purpose for the UI, just that you'll have to split the url at '#' using Javascript.
This will work for you <%= link_to "title", resource_path(:anchor => "anchor") %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With