Search code examples
ruby-on-railsruby-on-rails-3loggingruby-on-rails-2

(config.filter_parameters) equivalent for Rails 2.3.5


I need a config.filter_parameters (Rails 3.x.x) equivalent for Rails 2.3.x

module SampleApp
  class Application < Rails::Application
    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]
  end
end

That works on Rails 3 but it need that functionality in Rails 2.3.x.


Solution

  • Put the following inside your controller:

    filter_parameter_logging :password
    

    You could put it into your application controller and have the behavior extend to all your controllers or you can put it into just the controllers that need filtering. I recommend the application controller approach because it is more of a whitelist approach that is less prone to error.