app/controllers/link_router_controller.rb in umlaut-3.1.1 vs app/controllers/link_router_controller.rb in umlaut-3.2.0

- old
+ new

@@ -23,10 +23,12 @@ clickthrough.service_response_id = svc_response.id clickthrough.save redirect_to calculate_url_for_response(svc_response) end + protected + # Used to calculate a destination/target url for an Umlaut response item. # # Pass in a ServiceType join object (not actually a ServiceResponse, sorry) # Calculates the URL for it, and then runs our link_out_filters on it, # returning the final calculated url. @@ -37,10 +39,12 @@ # Used from LinkController's index, def calculate_url_for_response(svc_response) svc = ServiceStore.instantiate_service!(svc_response.service_id, nil) destination = svc.response_url(svc_response, params) + raise_missing_url!(svc_response) if destination.blank? + # if response_url returned a string, it's an external url and we're # done. If it's something else, usually a hash, then pass it to # url_for to generate a url. if destination.kind_of?(String) url = destination @@ -57,6 +61,17 @@ else return url_for(params_preserve_xhr(destination)) end end protected :calculate_url_for_response -end \ No newline at end of file +end + +def raise_missing_url!(service_response) + svc_rsp_id = service_response.try(:id) + service_id = service_response.try(:service_id) + type = service_response.try(:service_type_value_name) + text = service_response.try(:display_text) + request_id = service_response.try(:request).try(:id) + request_url = service_response.try(:request).try(:http_env).try {|h| h["REQUEST_URI"] } + + raise ArgumentError.new("LinkRouterController#index missing URL to redirect to for ServiceResponse:#{svc_rsp_id} (#{service_id}/#{type}/#{text}) from original request url: #{request_url}") +end