title: Why ruby on rails link_to redirect to itself?
body: <p>Lets say I have a controler test.</p>
  
  <p>In test I define 3 actions:</p>
  
  <pre><code>def zah
  end
  def zeh
  end
  def zih
  end
  </code></pre>
  
  <p>I have the views:</p>
  
  <p>zah.html.erb
  <br>zeh.html.erb
  <br>zih.html.erb</p>
  
  <p>and under routes.rb I have:</p>
  
  <pre><code>get 'test/zah'
  get 'test/zeh'
  get 'test/zih'
  </code></pre>
  
  <p>If I write under zah.html.erb, using code automaticaly created from rubymine IDE, this:</p>
  
  <pre><code>&lt;%= link_to test_zeh_path%&gt;
  </code></pre>
  
  <p>I will get my page source code with this:</p>
  
  <pre><code>&lt;a href="/test/zah"&gt;http://localhost:3000/test/zeh&lt;/a&gt;
  </code></pre>
  
  <p>which makes the redirection from zah be itself.</p>
  
  <p>running rake routes returns this:</p>
  
  <pre><code>      Prefix Verb URI Pattern                 Controller#Action
  
      test_zah GET  /test/zah(.:format)         test#zah
      test_zeh GET  /test/zeh(.:format)         test#zeh
      test_zih GET  /test/zih(.:format)         test#zih
  </code></pre>
  
  <p>Can anyone explain to me why is the link going to itself (from zah to zah) instead of another page(from zah to zeh)?</p>
  
  <p>Edit:</p>
  
  <p>I have found out that adding a name to a link makes the generated code works right:</p>
  
  <pre><code>&lt;%= link_to 'zeh', test_zeh_path%&gt;
  </code></pre>
  
  <p>I have seen the first usage (link_to test_zeh_path) <a href="https://www.youtube.com/watch?v=E68pK6uhYpY&amp;index=3&amp;list=PLSXDqiI4sC5PsASjJy7dBncALnhjud2fx" rel="nofollow">here</a> at 22:45.</p>
  
  <p><a href="http://api.rubyonrails.org/" rel="nofollow">Ruby on rails api</a> does says that if nil name is passed then "the value of the link itself will become the name.".</p>
  
  <p>As for a mistake of myself I was wondering why Dave Jones was able to create a link without a name, but he wasnt and that can be seen on his source code.</p>