Handle the situation where config.workbench_address is unset more
authorWard Vandewege <ward@curoverse.com>
Tue, 11 Feb 2014 22:42:44 +0000 (17:42 -0500)
committerWard Vandewege <ward@curoverse.com>
Tue, 11 Feb 2014 22:42:44 +0000 (17:42 -0500)
gracefully: do not try to redirect and blow up, instead send a
json-encoded error message.

services/api/app/controllers/static_controller.rb

index ba69b8464f7407a4e1b1473a99c506b0a86c596d..fda088095e9f5e075f4fd52eaeea711e025280e7 100644 (file)
@@ -6,7 +6,13 @@ class StaticController < ApplicationController
   skip_before_filter :require_auth_scope_all, :only => [ :home, :login_failure ]
 
   def home
-    redirect_to Rails.configuration.workbench_address
+    if Rails.configuration.respond_to? :workbench_address
+      redirect_to Rails.configuration.workbench_address
+    else
+      render json: {
+        error: ('This is the API server; you probably want to be at the workbench for this installation. Unfortunately, config.workbench_address is not set so I can not redirect you there automatically')
+      }
+    end
   end
 
 end