Created
June 24, 2015 04:49
-
-
Save AlexandrBasan/304a5fe8e512078f6379 to your computer and use it in GitHub Desktop.
Add custom error using standard Rails error Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% 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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @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