views:

68

answers:

1

How can I prevent a certain parameter of a nested relationship in rails from entering the log file - I am writing LARGE files to a column in the db and don't want rails to write that to the log file.. I know of filter_parameter_logging but it doesn't seem to work for nested models - I may just be putting in the wrong spot?

+1  A: 

According to the Rails code this should work even for nested parameter hashes. You can implement the filter_parameters method on your controller to work around your issue. Read this thread for more details. I have posted the code from the thread above for your convenience.

  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
KandadaBoggu