Sha256: e04cf7bfbe98458ce77c83c7c8f8a1713e3a84fa0011c7ec19bbc7a4222edaba

Contents?: true

Size: 427 Bytes

Versions: 1

Compression:

Stored size: 427 Bytes

Contents

Spree::Address.class_eval do
  belongs_to :city, class_name: 'Spree::City'

  validates :number, :numericality => {greater_than: 0}, :presence => true
  validates :district, length: { maximum: 150}, presence: true

  before_validation :sanitize_phone

  def phone_area_code
    phone[0..1] if phone
  end

  def phone_number
    phone[2..-1] if phone
  end

  private
  def sanitize_phone
    phone.gsub!(/[^\d]/, '')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_br_common-1.1.3 app/models/spree/address_decorator.rb