Skip to content

Instantly share code, notes, and snippets.

@jlindley
Created December 23, 2008 18:09
Show Gist options
  • Save jlindley/39408 to your computer and use it in GitHub Desktop.
Save jlindley/39408 to your computer and use it in GitHub Desktop.
if rails_env = ENV['RAILS_ENV']
rails_root = File.basename(Dir.pwd)
rails_env_string = case rails_env
when 'development'
'dev'
when 'production'
'prod'
else
rails_env
end
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:RAILS] = {
:PROMPT_I => "#{rails_root} #{rails_env_string}> ",
:PROMPT_S => "#{rails_root} #{rails_env_string}* ",
:PROMPT_C => "#{rails_root} #{rails_env_string}? ",
:RETURN => "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :RAILS
# Called after the irb session is initialized and Rails has
# been loaded (props: Mike Clark).
IRB.conf[:IRB_RC] = Proc.new do
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.instance_eval { alias :[] :find }
alias :r! :reload!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment