Skip to content

Instantly share code, notes, and snippets.

@thibaudgg
Created June 12, 2010 19:41
Show Gist options
  • Save thibaudgg/436008 to your computer and use it in GitHub Desktop.
Save thibaudgg/436008 to your computer and use it in GitHub Desktop.
irbrc compatible with Rails 3
# ===========
# = 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