tap/app/views/stocks/_errors.html.erb
2015-09-02 12:57:41 +02:00

13 lines
604 B
Text

<% 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 %>