Skip to content

Instantly share code, notes, and snippets.

@baldwindavid
Created September 14, 2009 19:22
Show Gist options
  • Save baldwindavid/186864 to your computer and use it in GitHub Desktop.
Save baldwindavid/186864 to your computer and use it in GitHub Desktop.
# needs refactored...but not today
module ApplicationHelper
def display_address(obj, args = {})
args = {
:address_1 => obj.respond_to?('address_1') ? obj.address_1 : obj.address1,
:address_2 => obj.respond_to?('address_2') ? obj.address_2 : obj.address2,
:city => obj.city,
:state => obj.respond_to?('state_abbrev') ? obj.state_abbrev : obj.state,
:zipcode => obj.respond_to?('zipcode') ? obj.zipcode : obj.zip_code,
:lines => 1
}.merge(args)
"#{args[:address_1]}#{', ' + args[:address_2] unless args[:address_2].blank?}#{args[:lines] > 1 ? '<br />' : ', ' }#{args[:city]}, #{args[:state]} #{args[:zipcode]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment