1

My terminal used to display SQL table insert statements (as it should by default), and now it doesn't. Everything else - for example, GET requests, or local server startup info, or job completion notifications - appear as normal.

For the life of me, I can't figure out what the problem could be. I've been searching for a long time and can't figure out any reason this would happen. Do you have any ideas to point me in the right direction?

CodeBiker
  • 2,985
  • 2
  • 33
  • 36

1 Answers1

4

Put this in either in your .irbrc or .pryrc in your home directory

if defined?(Rails) && !Rails.env.nil?
  puts '... ActiveRecord and ActiveResource Logger set to STDOUT'
  logger = Logger.new(STDOUT)
  ActiveRecord::Base.logger = logger
  ActiveResource::Base.logger = logger
end

You should start to see the sql statements executing in the rails console. Hope this helps

fontno
  • 6,642
  • 6
  • 36
  • 43
  • Thank you for your response. I don't have any file by that name, as far as I can find, on my computer. I have a Mac - would that change things? I do have a .bashrc and a .zshrc in my home directory. – CodeBiker May 16 '13 at 21:01
  • It's working perfectly now - brilliant! I couldn't find those files you mentioned in my home directory, but I just created an initializer file in my Rails app's Initializers folder and entered in your code. – CodeBiker May 16 '13 at 21:10
  • 1
    No problem. You have to create it if its not there. Its just an irb preference file. At the root of your home directory create the file, `touch ~/.irbrc`. Now open it in your editor and add the code. Rails console uses irb by default. If you want to use pry (a more modern version of irb) do the same thing but use `~/.pryrc instead` and install the `pry-rails` gem. Let me know if you have more questions. happy to help – fontno May 16 '13 at 21:11
  • Ah, got it - that's good to know. I'll do that so this preference will be the standard for my other Rails apps as well. – CodeBiker May 16 '13 at 21:14