Files
openfoodnetwork/app/controllers/concerns/raising_parameters.rb
Maikel Linke 41746459fa Restrict allow_charges attribute to read-only
We want people to use the UI to change this attribute.
2022-03-28 10:55:57 +11:00

24 lines
768 B
Ruby

# frozen_string_literal: true
# The API uses strict parameter checking.
#
# We want to raise errors when unused or unpermitted parameters are given
# to the API. You then know straight away when a parameter isn't used.
module RaisingParameters
extend ActiveSupport::Concern
# ActionController manages this config on a per-class basis. The subclass
# enables us to raise errors only here and not in the rest of the app.
class Parameters < ActionController::Parameters
def self.action_on_unpermitted_parameters
:raise
end
end
# We override the params method so that we always use the strict parameters.
# We could rename this method if we need access to the orginal as well.
def params
Parameters.new(super.to_unsafe_hash)
end
end