Filter_parameter_logging

Hi,

Is there a way to specify keys of a hash in params to
filter_parameter_logging.

For example, my payment form sends creditcard[:number] and
creditcard[:type] in params and I filter these keys using
filter_parameter_logging :number, :type.

I don’t want :number and :type in other forms to be filtered. Is there
a way to solve this?

thanks,
Ritesh

ritesh wrote:

Hi,

Is there a way to specify keys of a hash in params to
filter_parameter_logging.

For example, my payment form sends creditcard[:number] and
creditcard[:type] in params and I filter these keys using
filter_parameter_logging :number, :type.

I don’t want :number and :type in other forms to be filtered. Is there
a way to solve this?

thanks,
Ritesh

This condition is more advanced that filter_parameter_logging is
designed to handle. You’ll need to define your own filter_parameters
method for the controller. Here’s an example that may work for you:

def filter_parameters(unfiltered)
return unfiltered unless params[:action] == ‘payment’
filtered = unfiltered.dup
filtered[:creditcard] = unfiltered[:creditcard].dup
filtered[:creditcard][:number] = ‘[FILTERED]’
filtered[:creditcard][:type] = ‘[FILTERED]’
filtered
end

Jeremy