Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails避免将嵌套对象的属性写入日志_Ruby On Rails_Logging_Nested Attributes - Fatal编程技术网

Ruby on rails Rails避免将嵌套对象的属性写入日志

Ruby on rails Rails避免将嵌套对象的属性写入日志,ruby-on-rails,logging,nested-attributes,Ruby On Rails,Logging,Nested Attributes,如何防止rails中嵌套关系的某个参数进入日志文件?我正在将大文件写入db中的一列,不希望rails将其写入日志文件。。我知道过滤参数日志记录,但它似乎对嵌套模型不起作用-我可能只是放错了位置?根据Rails代码,即使对嵌套参数哈希也应该起作用。 您可以在控制器上实现filter_parameters方法来解决您的问题。阅读线程了解更多详细信息。 为了您的方便,我已经发布了上面线程中的代码 def filter_parameters(unfiltered) return unfilt

如何防止rails中嵌套关系的某个参数进入日志文件?我正在将大文件写入db中的一列,不希望rails将其写入日志文件。。我知道过滤参数日志记录,但它似乎对嵌套模型不起作用-我可能只是放错了位置?

根据Rails代码,即使对嵌套参数哈希也应该起作用。 您可以在控制器上实现filter_parameters方法来解决您的问题。阅读线程了解更多详细信息。 为了您的方便,我已经发布了上面线程中的代码

  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