Rails console is not outputting SQL Statements to my Development Log

后端 未结 2 2040
攒了一身酷
攒了一身酷 2021-01-30 07:24

When I access my Webrick server via the localhost, or when I run rails migrations, my development.log is correctly written to. However, when I bootup my rails console with \"ra

2条回答
  •  逝去的感伤
    2021-01-30 07:58

    I am in Rails 2.3.8, the above answer doesn't really work for me.

    ActiveRecord::Base.logger = Logger.new STDOUT
    

    The following actually works:

    ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT)
    

    Reference http://www.shanison.com/2012/03/05/show-sql-statements-in-rails-console/

提交回复
热议问题