Sha256: 375f4a7c01bc177c5308a3e9f2863cd45e674325bcbb3e6642364e399f6e62b3
Contents?: true
Size: 1005 Bytes
Versions: 1
Compression:
Stored size: 1005 Bytes
Contents
class Address < ActiveRecord::Base belongs_to :vcard # Validations include I18nHelpers def validate_address errors.add_on_blank(:postal_code) errors.add_on_blank(:locality) if street_address.blank? and extended_address.blank? and post_office_box.blank? errors.add(:street_address, "#{t_attr(:street_address, Vcard)} #{I18n.translate('errors.messages.empty')}") errors.add(:extended_address, "#{t_attr(:extended_address, Vcard)} #{I18n.translate('errors.messages.empty')}") errors.add(:post_office_box, "#{t_attr(:post_office_box, Vcard)} #{I18n.translate('errors.messages.empty')}") end end # Helpers def to_s I18n.translate('has_vcards.address.to_s', :street_address => street_address, :postal_code => postal_code, :locality => locality ) end # Composed attributes def zip_locality "#{postal_code} #{locality}" end def zip_locality=(value) self.postal_code, self.locality = value.split(' ', 2) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
has_vcards-0.19.0 | app/models/address.rb |