app/models/address.rb in artfully_ose-1.0.0.rc4 vs app/models/address.rb in artfully_ose-1.1.0.rc1

- old
+ new

@@ -1,7 +1,7 @@ class Address < ActiveRecord::Base - attr_accessible :address1, :address2, :city, :state, :zip, :country + attr_accessible :address1, :address2, :city, :state, :zip, :country, :person_id belongs_to :person validates :person_id, :presence => true def address @@ -20,24 +20,11 @@ zip.eql?(addr.zip) && country.eql?(addr.country) end def self.from_payment(payment) - if payment.respond_to? "billing_address" - billing_address = payment.billing_address - - new({ - :address1 => billing_address.street_address1, - :address2 => billing_address.street_address2, - :city => billing_address.city, - :state => billing_address.state, - :zip => billing_address.postal_code, - :country => billing_address.country - }) - else - nil - end + payment.try(:customer).try(:address) end def self.unhash(address) (address.is_a? Hash) ? Address.new(address) : address end @@ -55,12 +42,15 @@ self.send("#{field}=", address.send(field)) end if save extra = updated_by.nil? ? "" : " from #{updated_by}" + text = "address updated#{extra}" + text = text + ", old address was: (#{old_addr})" unless old_addr.blank? note = person.notes.create({ :occurred_at => DateTime.now.in_time_zone(time_zone), - :text => "address updated#{extra}, old address was: (#{old_addr})" }) + :text => text + }) note.user = user else return false end end