Skip to content

Instantly share code, notes, and snippets.

@rslhdyt
Created June 9, 2021 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rslhdyt/12f62f5c144c60d452b7e406bcf46b33 to your computer and use it in GitHub Desktop.
Save rslhdyt/12f62f5c144c60d452b7e406bcf46b33 to your computer and use it in GitHub Desktop.
Manually filter parameters or hash based on filter parameter logging config in ruby on rails application
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += %i[
passw password vendorable_id
]
filters = Rails.application.config.filter_parameters
params = {
name: 'banana',
vendorable_id: 'secret'
}
f = ActiveSupport::ParameterFilter.new filters
f.filter params
# {name: 'banana', vendorable_id: [Filtered]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment