1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use the instrumentation framework to instrument Strong Params

This commit is contained in:
Daniel Schierbeck 2013-03-07 10:41:05 +01:00
parent 12f785fdc7
commit d552d8fa00
2 changed files with 7 additions and 1 deletions

View file

@ -48,6 +48,11 @@ module ActionController
info("Sent data #{event.payload[:filename]} (#{event.duration.round(1)}ms)")
end
def unpermitted_parameters(event)
unpermitted_keys = event.payload[:keys]
debug("Unpermitted parameters: #{unpermitted_keys.join(", ")}")
end
%w(write_fragment read_fragment exist_fragment?
expire_fragment expire_page write_page).each do |method|
class_eval <<-METHOD, __FILE__, __LINE__ + 1

View file

@ -339,7 +339,8 @@ module ActionController
if unpermitted_keys.any?
case self.class.action_on_unpermitted_parameters
when :log
ActionController::Base.logger.debug "Unpermitted parameters: #{unpermitted_keys.join(", ")}"
name = "unpermitted_parameters.action_controller"
ActiveSupport::Notifications.instrument(name, keys: unpermitted_keys)
when :raise
raise ActionController::UnpermittedParameters.new(unpermitted_keys)
end