4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RailsのLogでのパラメータをFILTEREDする。

Last updated at Posted at 2015-06-29

Railsでpasswordパラメータはデフォルトで見えなくなってますね。

Started POST "/users" for ::1 at 2015-06-29 14:16:14 +0900
Processing by UsersController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"ZrB1VEJ6B0nd7GxJ/BkxybIpF2jAyqhT6DjCx6YOuOXyK6kRBn75IPeN1RO/DHhEvJ1VyA96H6XHg8Cfsb6Jww==", "user"=>{"email"=>"test@hogehoge.com", "password"=>"[FILTERED]"}, "commit"=>"submit"}

ここにemailもLogに見せたくない場合。

config/initializers/filter_parameter_logging.rb
Rails.application.config.filter_parameters += [:password]

# emailも付与する
Rails.application.config.filter_parameters += [:password, :email]

こうすると、↓になる。

Started POST "/users" for ::1 at 2015-06-29 14:18:34 +0900
Processing by UsersController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"ZrB1VEJ6B0nd7GxJ/BkxybIpF2jAyqhT6DjCx6YOuOXyK6kRBn75IPeN1RO/DHhEvJ1VyA96H6XHg8Cfsb6Jww==", "user"=>{"email"=>"[FILTERED]", "password"=>"[FILTERED]"}, "commit"=>"submit"}
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?