Simple Script/Console Function
This is something simple I worked up today for my ZSH profile that let's me keep my simple sc
alias and have it work with all versions of rails. If you did not know, all the script files in rails 3 are gone and the new all-in-one rails
executable does all the heavy lifting. This little function even passes down all the arguments too.
sc () {
if [ -f ./script/rails ]; then
rails console $argv
else
./script/console $argv
fi
}
One other thing, the way rails uses IRB is different now. I had to change my ~/.irbrc
file to look like this below to get my simple prompt and history back. IMPORTANT NOTE: In order for this to work, you have to apply this 2 line patch to your save-history.rb file. Worked like a champ for me.
# IRB history patch <http://redmine.ruby-lang.org/issues/show/1556>
require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:USE_READLINE] = true
IRB.conf[:SAVE_HISTORY] = 500
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb.hist"
IRB.conf[:PROMPT_MODE] = :SIMPLE