Permalink
Browse files

Fix related file for controller action

Closes #158.
  • Loading branch information...
1 parent 9b3643b commit 04c7b18f66963e3bdb6307052c2dbeb89aad7ead @tpope committed May 3, 2012
Showing with 4 additions and 5 deletions.
  1. +4 −5 autoload/rails.vim
View
@@ -3043,12 +3043,11 @@ function! s:readable_related(...) dict abort
if a:0 && a:1
let lastmethod = self.last_method(a:1)
if self.type_name('controller','mailer') && lastmethod != ""
- let root = s:sub(s:sub(s:sub(f,'/application%(_controller)=\.rb$','/shared_controller.rb'),'/%(controllers|models|mailers)/','/views/'),'%(_controller)=\.rb$','/'.lastmethod)
- let format = self.format(a:1)
- if glob(self.app().path().'/'.root.'.'.format.'.*[^~]') != ''
- return root . '.' . format
+ let view = self.resolve_view(lastmethod, line('.'))
+ if view !=# ''
+ return view
else
- return root
+ return s:sub(s:sub(s:sub(f,'/application%(_controller)=\.rb$','/shared_controller.rb'),'/%(controllers|models|mailers)/','/views/'),'%(_controller)=\.rb$','/'.lastmethod)
endif
elseif f =~ '\<config/environments/'
return "config/database.yml#". fnamemodify(f,':t:r')

0 comments on commit 04c7b18

Please sign in to comment.