Shell function/alias for rails console/server etc, to work with rails 2 & 3
Rails 3 introduced the rails {c,s,g}
command format for invoking the console, server, generators and so on.
Back with rails 2 I had alias c=script/console
and others set up to alleviate typing.
I'd like the same for rails 3 but I sti开发者_开发技巧ll maintain rails 2 apps. Could I have a shell alias/function/other that checked for the existence of script/foo and ran it if present, else run the rails 3 equivalents?
Sorry for the lazy question; bash/zsh scripting is designed to rot one's brane imho and I'm rather hoping someone will have tackled this already.
Use the -f
test
alias c="if [ -f script/console ]; then script/console; else script/rails console; fi"
精彩评论