Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Created April 2, 2012 15:41
Show Gist options
  • Save iloveitaly/2284493 to your computer and use it in GitHub Desktop.
Save iloveitaly/2284493 to your computer and use it in GitHub Desktop.
Rails Snippets
def google_map_directions(address)
if address.class != String
address = [:address, :address2, :city, :state, :zipcode, :country].map {
|a| (address.respond_to? a) ? address.send(a) : ""
}.join " "
end
q = Rack::Utils::build_query({
:f => "q",
:hl => "en",
:saddr => "",
:daddr => address
})
"http://maps.google.com/maps?#{q}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment