Created
April 20, 2011 13:47
-
-
Save vidmantas/931370 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/.irbrc: | |
require 'irb/completion' | |
require 'irb/ext/save-history' | |
# where history is saved | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history" | |
# how many lines to save | |
IRB.conf[:SAVE_HISTORY] = 1000 | |
# detects a rails console, cares about version | |
def rails?(*args) | |
version=args.first | |
v2 = ($0 == 'irb' && ENV['RAILS_ENV']) | |
v3 = ($0 == 'script/rails' && Rails.env) | |
version == 2 ? v2 : version == 3 ? v3 : v2 || v3 | |
end | |
# loading rails configuration if it is running as a rails console | |
load "#{ENV['HOME']}/.railsrc" if rails? | |
~/.railsrc: | |
require 'logger' | |
require 'hirb' | |
require 'activerecord' if rails?(2) | |
def enable_logger | |
log_to(Logger.new(STDOUT)) | |
end | |
def disable_logger | |
log_to(nil) | |
end | |
def log_to(logger) | |
ActiveRecord::Base.logger = logger | |
ActiveRecord::Base.clear_active_connections! | |
end | |
# logging into console by default | |
enable_logger | |
Hirb.enable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment