2011-03-08 08:44:27 +00:00
|
|
|
class HydrantsController < ApplicationController
|
|
|
|
respond_to :json
|
|
|
|
|
2011-03-17 20:53:05 +00:00
|
|
|
def index
|
|
|
|
@hydrants = Hydrant.find_closest(params[:lat], params[:lng])
|
|
|
|
unless @hydrants.blank?
|
|
|
|
respond_with @hydrants
|
|
|
|
else
|
|
|
|
render(:json => {"errors" => {"address" => ["Could not find address."]}})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-08 08:44:27 +00:00
|
|
|
def update
|
|
|
|
@hydrant = Hydrant.find(params[:id])
|
|
|
|
if @hydrant.update_attributes(params[:hydrant])
|
2011-03-17 18:46:06 +00:00
|
|
|
render(:json => @hydrant)
|
2011-03-08 08:44:27 +00:00
|
|
|
else
|
|
|
|
render(:json => {"errors" => @hydrant.errors})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|