No commit activity in last 3 years
No release in over 3 years
This is not rocket science at all, this gem just adds a helper method to retrieve human friendly errors from ActiveRecord models.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 3.0.0, ~> 4.0.4
>= 3.0.0, ~> 4.0.4
>= 1.0
>= 10.0.0
~> 2.14.1
~> 1.3.9
 Project Readme

Activerecord::HumanizedErrors

Adds humanized error messages to ActiveRecord models, not rocket science at all.

Installation

Add this line to your application's Gemfile:

gem 'activerecord-humanized_errors'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activerecord-humanized_errors

Usage

Let's say, you have a model like this:

    class User < ActiveRecord::Base
       validates_presence_of :name, :email
    end

Then, on rails console you attempt to create a new user:

Loading development environment (Rails 4.0.3)
irb(main):001:0> User.create
  (0.2ms)  BEGIN
  (0.2ms)  ROLLBACK
=> #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>

Now you can make use of the humanized_errors method:

irb(main):002:0> _.humanized_errors
=> "Name can't be blank, Email can't be blank"

Compatibility

Preferred used on rails or activerecord >= 3.0.0 and ~> 4.0.4

Supports rails 2.3.18+, locking to v1.1.x

Contributing

  1. Fork it ( http://github.com/joiggama/activerecord-humanized_errors/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request