|
|
|
@ -36,12 +36,27 @@ alias rorx='_rails-command destroy'
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
function _rails-command {
|
|
|
|
|
if [[ -e "script/server" ]]; then
|
|
|
|
|
ruby script/"$@"
|
|
|
|
|
elif [[ -e "bin/rails" ]]; then
|
|
|
|
|
ruby bin/rails "$@"
|
|
|
|
|
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/'
|
|
|
|
|
else
|
|
|
|
|
ruby script/rails "$@"
|
|
|
|
|
print "$0: not inside of a Rails application: $PWD" >&2
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
(cd "$root_dir" && ruby "$rails_cmd" "$@")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|