2011-03-08 08:44:27 +00:00
|
|
|
class HydrantsController < ApplicationController
|
2011-05-31 11:12:02 +00:00
|
|
|
respond_to :json
|
2011-05-06 02:38:25 +00:00
|
|
|
|
2011-03-27 18:45:58 +00:00
|
|
|
def show
|
2011-08-09 18:48:47 +00:00
|
|
|
@hydrants = Hydrant.find_closest(params[:lat], params[:lng], params[:limit] || 20)
|
2011-03-17 20:53:05 +00:00
|
|
|
unless @hydrants.blank?
|
2011-05-06 02:38:25 +00:00
|
|
|
respond_with @hydrants
|
2011-03-17 20:53:05 +00:00
|
|
|
else
|
2011-09-15 00:36:44 +00:00
|
|
|
render(:json => {"errors" => {"address" => [t("errors.hydrants")]}}, :status => 404)
|
2011-03-17 20:53:05 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-08 08:44:27 +00:00
|
|
|
def update
|
|
|
|
@hydrant = Hydrant.find(params[:id])
|
|
|
|
if @hydrant.update_attributes(params[:hydrant])
|
2011-05-06 02:38:25 +00:00
|
|
|
respond_with @hydrant
|
2011-03-08 08:44:27 +00:00
|
|
|
else
|
2011-05-16 06:32:46 +00:00
|
|
|
render(:json => {"errors" => @hydrant.errors}, :status => 500)
|
2011-03-08 08:44:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|