adopt-a-hydrant/app/controllers/things_controller.rb

22 lines
552 B
Ruby
Raw Normal View History

class ThingsController < ApplicationController
respond_to :json
def show
@things = Thing.find_closest(params[:lat], params[:lng], params[:limit] || 10)
unless @things.blank?
respond_with @things
else
2012-06-18 17:49:28 +00:00
render(json: {errors: {address: [t("errors.not_found", thing: t("defaults.thing"))]}}, status: 404)
end
end
def update
@thing = Thing.find(params[:id])
if @thing.update_attributes(params[:thing])
respond_with @thing
else
2012-06-18 17:49:28 +00:00
render(json: {errors: @thing.errors}, status: 500)
end
end
end