Skip to content

Instantly share code, notes, and snippets.

@jimmybaker
Created June 14, 2009 20:49
Show Gist options
  • Save jimmybaker/129809 to your computer and use it in GitHub Desktop.
Save jimmybaker/129809 to your computer and use it in GitHub Desktop.
def set_default
if addressable.kind_of?(User)
if default_shipping?
addressable.addresses.default_shipping.without(self).each{|a| a.update_attribute(:default_shipping, false) }
else
default_shipping = true if addressable.addresses.default_shipping.empty?
end
if default_billing?
addressable.addresses.default_billing.without(self).each{|a| a.update_attribute(:default_billing, false) }
else
default_billing = true if addressable.addresses.default_shipping.empty?
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment