box-o-sand/rails/map-mash/app/controllers/maps_controller.rb

29 lines
622 B
Ruby

class MapsController < ApplicationController
def index
@maps = Map.all
respond_to do |format|
format.html
format.xml { render :xml => @maps }
end
end
def show
@map = Map.find(params[:id])
respond_to do |format|
format.png do
GoogleMapLocationFetcher.new.fetch([@map.name]) do |loc,image|
dest = Rails.root.join("public/maps/#{@map.id}.png")
FileUtils.mkdir_p(File.dirname(dest))
File.open(dest, 'w') do |f|
f.write(image)
end
send_file(dest, :type => 'image/png')
end
end
end
end
end