2012-02-01 05:37:51 +01:00
|
|
|
#
|
|
|
|
# Defines Ruby on Rails aliases.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Robby Russell <robby@planetargon.com>
|
|
|
|
# Jake Bell <jake.b.bell@gmail.com>
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2012-07-23 21:00:44 +02:00
|
|
|
# Return if requirements are not found.
|
|
|
|
if (( ! $+commands[rails] )); then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2012-08-04 20:48:32 +02:00
|
|
|
#
|
2012-06-15 01:05:12 +02:00
|
|
|
# Aliases (Compatible with Rails 2)
|
2012-08-04 20:48:32 +02:00
|
|
|
#
|
|
|
|
|
2012-08-15 03:13:07 +02:00
|
|
|
alias ror='rails'
|
|
|
|
alias rorc='_rails-command console'
|
|
|
|
alias rordc='_rails-command dbconsole'
|
|
|
|
alias rordm='rake db:migrate'
|
|
|
|
alias rordM='rake db:migrate db:test:clone'
|
|
|
|
alias rordr='rake db:rollback'
|
|
|
|
alias rorg='_rails-command generate'
|
|
|
|
alias rorl='tail -f log/development.log'
|
|
|
|
alias rorlc='rake log:clear'
|
|
|
|
alias rorp='_rails-command plugin'
|
|
|
|
alias rorr='_rails-command runner'
|
|
|
|
alias rors='_rails-command server'
|
|
|
|
alias rorsd='_rails-command server --debugger'
|
|
|
|
alias rorx='_rails-command destroy'
|
2010-06-03 21:32:55 +02:00
|
|
|
|
2012-08-04 20:48:32 +02:00
|
|
|
#
|
2011-08-31 05:16:15 +02:00
|
|
|
# Functions
|
2012-08-04 20:48:32 +02:00
|
|
|
#
|
|
|
|
|
2012-03-23 19:57:51 +01:00
|
|
|
function _rails-command {
|
2013-11-25 22:11:08 +01:00
|
|
|
local root_dir="$PWD"
|
|
|
|
local rails_cmd
|
|
|
|
|
|
|
|
while [[ "$root_dir" != '/' ]]; do
|
|
|
|
if [[ -d "$root_dir/.bundle" ]]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
root_dir="$root_dir:h"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ -e "$root_dir/bin/rails" ]]; then
|
|
|
|
rails_cmd='bin/rails'
|
|
|
|
elif [[ -e "$root_dir/script/rails" ]]; then
|
|
|
|
rails_cmd='script/rails'
|
|
|
|
elif [[ -e "$root_dir/script/server" ]]; then
|
|
|
|
rails_cmd='script/'
|
2011-08-31 05:16:15 +02:00
|
|
|
else
|
2013-11-25 22:11:08 +01:00
|
|
|
print "$0: not inside of a Rails application: $PWD" >&2
|
|
|
|
return 1
|
2011-08-31 05:16:15 +02:00
|
|
|
fi
|
2013-11-25 22:11:08 +01:00
|
|
|
|
|
|
|
(cd "$root_dir" && ruby "$rails_cmd" "$@")
|
2010-06-03 21:55:07 +02:00
|
|
|
}
|
2011-08-31 05:16:15 +02:00
|
|
|
|