README.md in enum_help-0.0.5 vs README.md in enum_help-0.0.6

- old
+ new

@@ -29,28 +29,38 @@ required Rails 4.1.x In model file: class Order < ActiveRecord::Base - enum status: { "nopayment" => 0, "finished" => 1 } + enum status: { "nopayment" => 0, "finished" => 1, "failed" => 2, "destroyed" => 3 } + + def self.restricted_statuses + statuses.except :failed, :destroyed + end end You can call: order = Order.first order.update_attribute :status, 0 order.status # > nopayment - order.status_i18n - # > nopayment or 未支付 + order.status_i18n # if you have an i18n file defined as following, it will return "未支付". + # > 未支付 In _form.html.erb using simple form: <%= f.input :status %> This will generate select field with translations automaticlly. +And if you want to generate select except some values, then you can pass a collection option. + + <%= f.input :status Order.restricted_statuses %> + + + Other arguments for simple_form are supported perfectly. e.g. <%= f.input :status, prompt: 'Please select a stauts' %> @@ -65,13 +75,15 @@ enums: order: status: finished: 完成 nopayment: 未支付 + failed: 失败 + destroyed: 已删除 - ## Thanks * [mrhead](https://github.com/mrhead) +* [Jin Lee](https://github.com/neojin) ## Contributing 1. Fork it ( http://github.com/zmbacker/enum_help/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`)