I am trying to link to an element on the same page using link_to
in basic HTML i would do this
<a href="#tom">Tom Roche</a>
<a id="tom">Chapter 4</a>
I have this in my app
<%= link_to 'Tom Roche' %>
<h2>Tom Roche</h2>
How would i link these so that when i click on Tom Roche i get taken to the h2 with Tom Roche
I have tried this
<%= link_to 'Tom Roche', our_team_path(:anchor => '#tom') %>
<h2><a id="tom">Tom Roche</a></h2>
but its not working
Can anyone point out what i need to do, the link_to is throwing me for some reason, even though i know its an a tag
Thanks
link_to can also produce links with anchors or query strings:
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html