tap/app/views/stocks/_errors.html.erb

14 lines
604 B
Text
Raw Normal View History

2015-09-02 12:57:41 +02:00
<% unless @stock.valid? %>
<div class="panel panel-danger form-errors">
<div class="panel-heading">
<%= "#{pluralize(@stock.errors.count + @stock.stock_entries.map(&:errors).map(&:count).sum, "error")} prohibited this stock from being saved:" %>
</div>
<div class="panel-body">
<ul>
<%= @stock.errors.full_messages.map{ |m| content_tag(:li, m) }.join.html_safe %>
<%= @stock.stock_entries.map{ |se| se.errors.full_messages.map{ |e| "#{se.product.name}: #{e}" } }.flatten.map{ |m| content_tag(:li, m) }.join.html_safe %>
</ul>
</div>
</div>
<% end %>