X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/63e8f77e963949d4187555411e7b5c60fc850468..35336cd73e444534cb2eda20e3730464cc4e6553:/services/api/app/controllers/application_controller.rb diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb index 8ed554f8ca..2d37dc18cd 100644 --- a/services/api/app/controllers/application_controller.rb +++ b/services/api/app/controllers/application_controller.rb @@ -39,7 +39,7 @@ class ApplicationController < ActionController::Base if @object.save show else - render_error "Save failed" + raise "Save failed" end end @@ -50,7 +50,7 @@ class ApplicationController < ActionController::Base if @object.update_attributes attrs_to_update show else - render_error "Update failed" + raise "Update failed" end end @@ -88,7 +88,9 @@ class ApplicationController < ActionController::Base def render_error(e) logger.error e.inspect - logger.error e.backtrace.collect { |x| x + "\n" }.join('') if e.backtrace + if e.respond_to? :backtrace and e.backtrace + logger.error e.backtrace.collect { |x| x + "\n" }.join('') + end if @object and @object.errors and @object.errors.full_messages and not @object.errors.full_messages.empty? errors = @object.errors.full_messages else @@ -313,7 +315,7 @@ class ApplicationController < ActionController::Base if supplied_token api_client_auth = ApiClientAuthorization. includes(:api_client, :user). - where('api_token=? and (expires_at is null or expires_at > now())', supplied_token). + where('api_token=? and (expires_at is null or expires_at > CURRENT_TIMESTAMP)', supplied_token). first if api_client_auth.andand.user session[:user_id] = api_client_auth.user.id @@ -444,13 +446,15 @@ class ApplicationController < ActionController::Base end def render *opts - response = opts.first[:json] - if response.is_a?(Hash) && - params[:_profile] && - Thread.current[:request_starttime] - response[:_profile] = { - request_time: Time.now - Thread.current[:request_starttime] - } + if opts.first + response = opts.first[:json] + if response.is_a?(Hash) && + params[:_profile] && + Thread.current[:request_starttime] + response[:_profile] = { + request_time: Time.now - Thread.current[:request_starttime] + } + end end super *opts end