Skip to content

Instantly share code, notes, and snippets.

@AlexandrBasan
Created June 24, 2015 04:49
Show Gist options
  • Save AlexandrBasan/304a5fe8e512078f6379 to your computer and use it in GitHub Desktop.
Save AlexandrBasan/304a5fe8e512078f6379 to your computer and use it in GitHub Desktop.
Add custom error using standard Rails error Model
<% if object and object.errors.any? %>
<div class="error_explanation">
<h2><%= pluralize(object.errors.count, "error") %> prohibited this <%= object.class.model_name.human.downcase %> from being saved:</h2>
<ul>
<% object.errors.full_messages.each do |msg| %>
<li>* <%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<% @user.errors.add(:base, "either name or email must be present") %>
<%= render 'admin/shared/error_messages', object: @user %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment