title: Rails ERB iterate over array
body: <p>I'm trying to experiment with blocks and how to iterate over collections in ERB. I have a models in a one-to-many relatinship (Channel and their corresponding types).</p>
  <h1>controller</h1>
  <pre><code>class HomePageController &lt; ActionController
     def index
      @channels =  Channel.all
     end
  end
  </code></pre>
  <p>Then in the view, I iterate over all the attributes belonging to a Channel. When I want to print all types, this code gives me the desired output:</p>
  <h1>view</h1>
  <pre><code>&lt;% @channels.each do |channel| %&gt;
      &lt;% @types.each do |type| %&gt;
          &lt;%= Type.find(type).name %&gt;
      &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  <p>At first I tried to achieve this by using the <code>yield</code> keyword in a neat one-liner but I couldn't manage to print anything to the browser, only to the console</p>
  <pre><code>&lt;% @types.each {|type| yield Type.find(type).name } %&gt;
  </code></pre>
  <p>Is there an equivalent one-liner?</p>