Skip to content

Support specifying a custom rails command #614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions autoload/rails.vim
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,9 @@ function! s:app_ruby_script_command(cmd) dict abort
endfunction

function! s:app_static_rails_command(cmd) dict abort
if filereadable(self.real('bin/rails'))
if exists('g:rails_cmd')
let cmd = g:rails_cmd
elseif filereadable(self.real('bin/rails'))
let cmd = 'bin/rails '.a:cmd
elseif filereadable(self.real('script/rails'))
let cmd = 'script/rails '.a:cmd
Expand Down Expand Up @@ -5041,7 +5043,7 @@ function! rails#buffer_setup() abort
if self.app().has_rails5()
call self.setvar('dispatch',
\ dir .
\ self.app().ruby_script_command('bin/rails') .
\ self.app().ruby_script_command( get(g:, 'rails_cmd', 'bin/rails') ) .
\ " %:s/.*/\\=rails#buffer(submatch(0)).default_task(exists('l#') ? l# : 0)/")
else
call self.setvar('dispatch',
Expand Down
6 changes: 6 additions & 0 deletions doc/rails.txt
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,12 @@ single project.
Gem maintainers may also provide custom projections by placing them in
lib/rails/projections.json.

*g:rails_cmd*
Set this if you want to specify a custom rails command. This could come in
handy if you wanted to run rails in docker for example:
>
let g:rails_cmd = 'docker compose run container bin/rails'
<
ABOUT *rails-about* *rails-plugin-author*

The latest stable version can be found at
Expand Down