Skip to content

Commit 5d973d4

Browse files
committed
Enable :Rview to work in mailers
1 parent 0195ff0 commit 5d973d4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

autoload/rails.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,7 +2511,7 @@ endfunction
25112511
function! s:viewEdit(cmd,...)
25122512
if a:0 && a:1 =~ '^[^!#:]'
25132513
let view = matchstr(a:1,'[^!#:]*')
2514-
elseif RailsFileType() == 'controller'
2514+
elseif rails#buffer().type_name('controller','mailer')
25152515
let view = s:lastmethod(line('.'))
25162516
else
25172517
let view = ''
@@ -2541,7 +2541,7 @@ function! s:viewEdit(cmd,...)
25412541
elseif file =~ '\.\w\+$'
25422542
call s:findedit(a:cmd,file)
25432543
else
2544-
let format = s:format('html')
2544+
let format = s:format(rails#buffer().type_name('mailer') ? 'text' : 'html')
25452545
if glob(rails#app().path(file.'.'.format).'.*[^~]') != ''
25462546
let file .= '.' . format
25472547
endif
@@ -2939,7 +2939,9 @@ function! s:readable_related(...) dict abort
29392939
if t =~ '^\%(controller\|mailer\)\>' && lastmethod != ""
29402940
let root = s:sub(s:sub(s:sub(f,'/application%(_controller)=\.rb$','/shared_controller.rb'),'/%(controllers|models|mailers)/','/views/'),'%(_controller)=\.rb$','/'.lastmethod)
29412941
let format = self.last_format(a:1)
2942-
if format == '' | let format = 'html' | endif
2942+
if format == ''
2943+
let format = t =~# '^mailer\>' ? 'text' : 'html'
2944+
endif
29432945
if glob(self.app().path().'/'.root.'.'.format.'.*[^~]') != ''
29442946
return root . '.' . format
29452947
else

0 commit comments

Comments
 (0)