Browse Source

Rewrite _rails-command to work from app subdirectories

master
Sorin Ionescu 11 years ago
parent
commit
5cfe250e52
  1. 25
      modules/rails/init.zsh

25
modules/rails/init.zsh

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

Loading…
Cancel
Save