title: Show error message in Flash alert Rails 3
body: <p>If I set a validation message up within my model </p>
  
  <pre><code>validates :name, :presence =&gt; {:message =&gt; 'The name cant be blank.'}
  </code></pre>
  
  <p>How do I get that message to show up in a flash alert, this is what i have tried so far</p>
  
  <pre><code>def create
     @message = Message.new(params[:message])
     if @message.valid?
       ContactMailer.send_mail(@message).deliver
       redirect_to(root_path, :notice =&gt; "Thanks for your message, I will be in touch soon")
     else
       flash[:error] = @message.errors
       render :new
     end
  end
  </code></pre>
  
  <p>but all i get is a black error message strip at the top of the page with no text in it, in my layout/application i have this</p>
  
  <pre><code>&lt;% flash.each do |name, msg| %&gt;
  &lt;div class="alert alert-&lt;%= name == :notice ? "success" : "error" %&gt;"&gt;
    &lt;%= content_tag :div, msg, :id =&gt; "flash_#{name}" if msg.is_a?(String) %&gt;
  &lt;/div&gt;
  </code></pre>
  
    
  
  <p>Any pointers appreciated</p>