After 9 years of writing Ruby on Rails code, link_to() never ceases to trip me up. Does it trip you up, too? Here are some quick notes:

  1. The first argument is what you want inside the <a> tag. For example link_to("today's news") produces <a>today's news</a>
  2. The second argument is the href attribute value. For example, link_to("today's news", "") produces <a href="">today's news</a>
  3. The third argument is a hash that contains everything else – most importantly, your <a> tag attributes. For example, link_to("today's news", "", {id: "newsbox", class: "infos"}) produces <a id="newsbox" class="infos" href="">today's news</a>. The third argument can contain many other options, of which I have never been able to find a definitive list.