# Model Error Messages [![Build Status](https://secure.travis-ci.org/christophemaximin/model_error_messages.png)](https://travis-ci.org/christophemaximin/model_error_messages) [![Gem version](https://badge.fury.io/rb/model_error_messages.png)](https://rubygems.org/gems/model_error_messages) [![Code Climate](https://codeclimate.com/github/christophemaximin/model_error_messages/badges/gpa.svg)](https://codeclimate.com/github/christophemaximin/model_error_messages) A simple Rails helper which displays a HTML div with the validation errors attached to a model. ## Install **Model Error Messages**'s installation is pretty standard, add the following line to your `Gemfile`, then run `bundle install`: ```rb gem 'model_error_messages' ``` ## What this gem does / How to use This gem allows you to use a helper called `model_error_messages`. By default, the wrapper `div` has the [Bootstrap](http://getbootstrap.com)-friendly classes `alert alert-danger`. If you have a typical form, you would want to display `model_error_messages(@model)` next to it, which will render something like: ```html
``` ... or if there is only one error: ```html

Title can't be blank

``` Example of integration: ```erb <%= model_error_messages(@article) %> <%= form_for @article do |f| %> <% end %> ``` ## What this gem doesn't do * Include any other dependencies * Influence the generation of errors * Inject or execute any code in your controllers and models * Do anything with the `flash` messages * Anything not listed in "What this gem does" ## Optional configuration You can change the default behavior of `model_error_messages` by: ## Setting an initializer Create a file `config/initializers/model_error_messages.rb` and replace one of the defaults: ```rb ModelErrorMessages.configure do |config| # Multiple errors will rendered in a several
  • in a