Created
June 12, 2010 19:41
-
-
Save thibaudgg/436008 to your computer and use it in GitHub Desktop.
irbrc compatible with Rails 3
This file contains 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
# =========== | |
# = Configs = | |
# =========== | |
%w[rubygems wirble pp].each do |gem| | |
begin | |
require gem | |
rescue LoadError => err | |
warn "Please do: gem install #{gem.sub(/\/.*/,'')}" | |
end | |
end | |
Wirble.init | |
Wirble.colorize | |
# ======================= | |
# = Convenience methods = | |
# ======================= | |
alias q exit | |
alias e exit | |
# ========= | |
# = Rails = | |
# ========= | |
def r; reload! end | |
# print SQL to STDOUT | |
# Rails 2 | |
if ENV.include?('RAILS_ENV') | |
unless Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' | |
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT)) | |
end | |
# Rails 3 | |
elsif defined?(Rails) | |
if Rails.logger | |
Rails.logger = Logger.new(STDOUT) | |
ActiveRecord::Base.logger = Rails.logger | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment