title: Link_to efficiency without fetching record
body: <p>In my Rails app there are <code>experiment</code> instances and each experiment has <code>attachments</code>, which are represented as binary blobs in the database and can be quite big. This question is about efficiency in coding a link_to show the attachment.</p>
  
  <p>Originally I had this:</p>
  
  <pre><code>&lt;%= link_to @experiment.attachment.file_name, @experiment.attachment %&gt;
  </code></pre>
  
  <p>However I was told that the Rails app would be more efficient in rendering the page with</p>
  
  <pre><code>&lt;%= link_to @experiment.attachment.file_name, {:controller =&gt; :attachments, :action =&gt; :show, :id =&gt; @experiment.attachment_id}, {:method =&gt; :get} if ! @experiment.attachment_id.nil? %&gt;
  </code></pre>
  
  <p>The justification is that the first version fetches the attachment from the database, and the second one does not, making it is better, albeit longer and uglier. Is this true? </p>
  
  <p>Both versions accomplish the same thing in directing the user to the show page for an attachment and I was under the impression the first is the default way to do a link_to a record show page. </p>
  
  <p>Is there a way to shorthand the second piece of code to make it less terrible with code in the view?</p>