title: Looping over an element in Rails 4 that encloses other elements with loops
body: <p>I am running issues using a <code>link_to</code> through a loop when there is another element encompassing the looped attributes. </p>
  
  <p>Here's what I mean. I am showing posts for a blog in an image - this image will contain multiple elements of content, all of which are being pulled from my table in Rails. </p>
  
  <p>With a stub as the link, this works fine, and it contains all of the image/post content within an <code>&lt;a&gt;</code> link: </p>
  
  <pre><code>&lt;ul id="hexGrid"&gt;
    &lt;li class="hex"&gt;
      &lt;a class="hexIn" href="#"&gt;
        &lt;img alt="rss feed" src="http://www.example/image.png" /&gt;
        &lt;h1&gt;Business Business Business &lt;/h1&gt;
        &lt;p&gt;Ipsum Incorporated is going to do something&lt;/p&gt;
      &lt;/a&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>That said, I want it to attach the associated link from my <code>Stub</code> column in my <code>Post</code> table, so I will adjust the code like so: </p>
  
  <pre><code>&lt;ul id="hexGrid"&gt;
    &lt;li class="hex"&gt;
      &lt;%= link_to post.slug, about_path(post.slug), class: "hexIn" %&gt;
        &lt;img alt="rss feed" src="http://www.example/image.png" /&gt;
        &lt;h1&gt;Business Business Business &lt;/h1&gt;
        &lt;p&gt;Ipsum Incorporated is going to do something&lt;/p&gt;
      &lt;/a&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Now I thought this looked great. I am still changing the link to be the <code>hexIn</code> class. However, the image posts end up being distorted and clearly wrong. </p>
  
  <p>After looking at the source code, I noticed that Rails is successfully changing <code>href</code> to the link from the table (good!) but attaching a closing ` after the link. Since in the original code, this link remains open until line 7, I believe that's causing the issue. </p>
  
  <pre><code>&lt;a class="hexIn" href="/about"&gt;&lt;/a&gt;
  </code></pre>
  
  <p>Is there any way I can prevent the dynamic addition of that <code>&lt;/a&gt;</code> in line 3 to fix this? Or another method? </p>