Sha256: f5cc0963406b62e6579f83196b4ae3fd01d4a0809883ac088c01d9af96d8bb28

Contents?: true

Size: 1017 Bytes

Versions: 3

Compression:

Stored size: 1017 Bytes

Contents

# == Schema Information
#
# Table name: purchases
#
#  id             :integer          not null, primary key
#  paid           :boolean
#  commission     :decimal(, )
#  quantity       :integer
#  state          :string
#  expired_at     :datetime
#  amount         :decimal(, )
#  description    :text
#  created_at     :datetime         not null
#  updated_at     :datetime         not null
#  payment_method :integer
#  shipping      :integer
#  store          :integer
#

require "enumerize"

class Purchase < ApplicationRecord
  extend Enumerize

  STATES = %i{pending canceled finished}

  enumerize :state, in: STATES, default: :pending
  enum payment_method: [:credit, :debit, :cash, :bitcoin]
  enum shipping: [:standard, :express]
  enum store: [:physical, :online]

  humanize_attributes
  humanize :state, enumerize: true
  humanize :commission, percentage: true
  humanize :amount, currency: true
  humanize :payment_method, enum: true
  humanize :shipping, enum: true
  humanize :store, enum: true
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
human_attributes-1.1.0 spec/dummy/app/models/purchase.rb
human_attributes-1.0.0 spec/dummy/app/models/purchase.rb
human_attributes-0.7.1 spec/dummy/app/models/purchase.rb