Generate human enumerize
Closed this issue · 0 comments
ldlsegovia commented
With
# == Schema Information
#
# Table name: purchases
#
# id :integer not null, primary key
# state :string
#
class Purchase < ActiveRecord::Base
extend Enumerize
STATES = %i{pending canceled finished}
enumerize :state, in: STATES, default: :pending
humanize :state, enumerize: true
end
purchase = Purchase.new
purchase.state = :pending
purchase.human_state #=> "Pending"
locales need to be defined as in https://github.com/brainspec/enumerize