README.md in human_attribute_values-0.0.1 vs README.md in human_attribute_values-0.0.2

- old
+ new

@@ -1,15 +1,19 @@ # human_attribute_values [![Build Status](https://travis-ci.org/RST-J/human_attribute_values.svg?branch=master)](https://travis-ci.org/RST-J/human_attribute_values) +[![Gem Version](https://badge.fury.io/rb/human_attribute_values.svg)](http://badge.fury.io/rb/human_attribute_values) human_attribute_values is a Rails plugin which provides translation for model attribute values using the Rails I18n API (analogously to [human_attribute_name](http://apidock.com/rails/v4.1.8/ActiveModel/Translation/human_attribute_name)). ## Installation +``` +gem install human_attribute_values +``` ## Supported versions - * Rails: 4.18 - * Ruby: tested for MRI 1.9 to 2.2 and Rubinius (JRuby should also work though) + * Rails: >= 4.1.8 + * Ruby: MRI >= 2.0 and Rubinius (JRuby should also work though) ## Usage The gem defines ``human_attribute_value`` on each model, both as instance and as class method. To translate a value it uses the I18n API. The translations are looked up from the current locale file under the key ``'activerecord.values.model_name.attribute_name.value'`` by default. @@ -19,28 +23,28 @@ activerecord: values: schroedinger: cat_status: dead_and_alive: The box is still closed. - alive: You opened the box and kitty purs. + alive: You opened the box and kitty purrs. ``` Translations: ```ruby class Schroedinger < ActiveRecord::Base enum cat_status: {dead_and_alive: 0, alive: 1, dead: 2} end -# Translate by calling human_attribute_value with the attribute to be translated on instances +# Translation on instances by passing the attribute to be translated Schroedinger.new(cat_status: :dead_and_alive).human_attribute_value(:cat_status) => "The box is still closed." -# Translate a value by passing attribute and value to human_attribute_value on the model class -Schroedinger.new.human_attribute_value(:cat_status, :alive) +# Translation on the model class by passing attribute and value +Schroedinger.human_attribute_value(:cat_status, :alive) => "You opened the box and kitty purs." # If there is no translation specified in the locale, the stringified value is returned -Schroedinger.new.human_attribute_value(:cat_status, :dead) +Schroedinger.human_attribute_value(:cat_status, :dead) => "dead" ``` ### Boolean values