2011-09-15 21:41:26 +00:00
|
|
|
class ThingsController < ApplicationController
|
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
def show
|
2012-01-14 22:31:01 +00:00
|
|
|
@things = Thing.find_closest(params[:lat], params[:lng], params[:limit] || 10)
|
2011-09-15 21:41:26 +00:00
|
|
|
unless @things.blank?
|
|
|
|
respond_with @things
|
|
|
|
else
|
|
|
|
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
|
|
|
|
render(:json => {"errors" => @thing.errors}, :status => 500)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|