<%= link_to 'Do Something', '#', :onclick=>'dosomething()' %>
This is great, except that it jumps you to the top of the page. Very annoying. Here is the solution:
<%= link_to 'Do Something', '#nogo', :onclick=>'dosomething()' %>
Notice I added “nogo” to my #. This will help prevent from jumping to the top of the page. You can of course use any text you want there.