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

Merge pull request #9626 from dasch/dasch/instrument-strong-params

Use AS::Notifications to instrument Strong Params
This commit is contained in:
José Valim 2013-03-09 12:35:23 -08:00
commit 6a18ec0a0d
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