Created
October 8, 2010 10:05
-
-
Save aalin/616586 to your computer and use it in GitHub Desktop.
Show rails environment in the rails console
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
| class IRB::Irb | |
| alias :original_prompt :prompt | |
| def prompt(prompt, ltype, indent, line_no) | |
| prompt = prompt.call if prompt.respond_to?(:call) | |
| original_prompt(prompt, ltype, indent, line_no) | |
| end | |
| end | |
| IRB.conf[:PROMPT_MODE] = :RAILS_ENV | |
| IRB.conf[:PROMPT][:RAILS_ENV] = IRB.conf[:PROMPT][:CLASSIC].merge(:PROMPT_I => lambda { (defined?(Rails) ? "#{Rails.env} " : "") + "%N(%m):%03n:%i> " }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI
gem 'marco-polo'does about the same and no custom hacks required :)