LoginSignup
11
4

More than 5 years have passed since last update.

binding.pryでsql文を表示したい時のおまじない

Posted at

binding.pryの中で

> ActiveRecord::Base.logger = Logger.new(STDOUT)
=> #<Logger:0x007f8664e4a740
 @default_formatter=#<Logger::Formatter:0x007f8664e4a718 @datetime_format=nil>,
 @formatter=nil,
 @level=0,
 @logdev=
  #<Logger::LogDevice:0x007f8664e4a6c8
   @dev=#<IO:<STDOUT>>,
   @filename=nil,
   @mutex=
    #<Logger::LogDevice::LogDeviceMutex:0x007f8664e4a6a0
     @mon_count=0,
     @mon_mutex=#<Mutex:0x007f8664e4a650>,
     @mon_owner=nil>,
   @shift_age=nil,
   @shift_size=nil>,
 @progname=nil>

すると

>  User.active.count
D, [2016-01-14T11:19:50.133183 #29031] DEBUG -- :   CACHE (0.0ms)  SELECT COUNT(*) FROM `users` WHERE `users`.`active_flag` = 1 AND `users`.`deleted_at` IS NULL AND (`users`.`global_user_id` IS NOT NULL)
11
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
11
4