Handle ActionController::ParameterMissing globally

See 6d11fac2.

Signed-off-by: Alex Coles <alex@alexbcoles.com>
pull/2229/head
Alex Coles 10 years ago
parent 6d11fac2f8
commit 3629ded2ae
  1. 5
      app/controllers/api/v2/api_controller.rb
  2. 5
      app/controllers/application_controller.rb

@ -33,11 +33,6 @@ module Api
module ClassMethods
def included(base)
base.class_eval do
rescue_from(ActionController::ParameterMissing) do |exception|
render text: "Required parameter missing: #{exception.param}",
status: :bad_request
end
if (respond_to? :skip_before_filter) && (respond_to? :prepend_before_filter)
skip_before_filter :disable_api
prepend_before_filter :disable_everything_except_api

@ -105,6 +105,11 @@ class ApplicationController < ActionController::Base
render_error status: 422, message: 'Invalid form authenticity token.' unless api_request?
end
rescue_from ActionController::ParameterMissing do |exception|
render text: "Required parameter missing: #{exception.param}",
status: :bad_request
end
before_filter :user_setup,
:check_if_login_required,
:log_requesting_user,

Loading…
Cancel
Save