Sha256: 5f998332df9f449ad7103918a3a9fb0648485161df59bc6bb91706df2270edbe
Contents?: true
Size: 987 Bytes
Versions: 16
Compression:
Stored size: 987 Bytes
Contents
module Piggybak class Address < ActiveRecord::Base belongs_to :state belongs_to :country validates_presence_of :firstname validates_presence_of :lastname validates_presence_of :address1 validates_presence_of :city validates_presence_of :state_id validates_presence_of :country_id validates_presence_of :zip after_initialize :set_default_country def set_default_country self.country ||= Country.find_by_abbr(Piggybak.config.default_country) end def admin_label address = "#{self.firstname} #{self.lastname}<br />" address += "#{self.address1}<br />" if self.address2 && self.address2 != '' address += "#{self.address2}<br />" end address += "#{self.city}, #{self.state_display} #{self.zip}<br />" address += "#{self.country.name}" address end alias :display :admin_label def state_display self.state ? self.state.name : self.state_id end end end
Version data entries
16 entries across 16 versions & 1 rubygems