fix error handling
authorTom Clegg <tom@clinicalfuture.com>
Wed, 16 Jan 2013 22:43:37 +0000 (14:43 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Wed, 16 Jan 2013 22:43:37 +0000 (14:43 -0800)
app/controllers/application_controller.rb

index dcd47a76efd25151a695b6bac5f21175f698ff41..6ea18ce315e3acbc0fd02e274e8ae81ba11df9c4 100644 (file)
@@ -29,7 +29,7 @@ class ApplicationController < ActionController::Base
 
   def render_not_found(e=ActionController::RoutingError.new("Path not found"))
     logger.error e.inspect
-    render json: { errors: ["Path not found"] }, status: 401
+    render json: { errors: ["Path not found"] }, status: 404
   end
 
   def index
@@ -38,7 +38,11 @@ class ApplicationController < ActionController::Base
   end
 
   def show
-    render json: @object.as_api_response(:superuser)
+    if @object
+      render json: @object.as_api_response(:superuser)
+    else
+      render_not_found("object not found")
+    end
   end
 
   def create