title: Rails: Iterating over array of strings inside hash (flash error messages)
body: <p>I'm trying to iterate over the following:</p>
  
  <pre><code>flash = {"danger"=&gt;["Password can't be blank", "Name can't be blank"]}
  </code></pre>
  
  <p>My code for iterating over these flash error messages is as follows:</p>
  
  <pre><code>  &lt;% flash.each do |name, message| %&gt;
      &lt;div class="alert alert-&lt;%= name %&gt;"&gt;
        &lt;%= message %&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>Here is how I am setting flash (I changed it to allow multiple errors, so I think):</p>
  
  <pre><code>  flash[:danger] = []
    @user.errors.full_messages.each do |message|
      flash[:danger] &lt;&lt; message
    end
  
    render :new
  </code></pre>
  
  <p>What I seem to get in return, instead of multiple div's with each error message separate, is the following (all within a div.alert alert-danger, which is correct): </p>
  
  <p>["Password can't be blank", "Name can't be blank"]</p>
  
  <p>I cannot seem to figure out how to simply iterate over each message individually. I need the key (danger) for my class, and the value (error message) to display in the div.</p>
  
  <p>Any help would be much appreciated!!</p>