diff --git a/app/controllers/api/v1/api_controller.rb b/app/controllers/api/v1/api_controller.rb index fea34fd..887eeaa 100644 --- a/app/controllers/api/v1/api_controller.rb +++ b/app/controllers/api/v1/api_controller.rb @@ -28,20 +28,10 @@ module Api render_error(e) end - unless Rails.env.production? - around_action :n_plus_one_detection - - def n_plus_one_detection - Prosopite.scan - yield - ensure - Prosopite.finish - end - end - ##### Hooks before_action :current_user before_action :default_content_type + around_action :n_plus_one_detection, unless: -> { Rails.env.production? } ##### Responders respond_to :json @@ -130,6 +120,13 @@ module Api def restrict_access raise UnauthorizedError unless current_user end + + def n_plus_one_detection + Prosopite.scan + yield + ensure + Prosopite.finish + end end end end