Permalink
Browse files

Fix :Rcontroller from view with no argument

Closes #207.
  • Loading branch information...
1 parent ffa28f9 commit eb8e977d5217766af1b50da8010632a01ec17a29 @tpope committed Jan 25, 2013
Showing with 6 additions and 3 deletions.
  1. +6 −3 autoload/rails.vim
View
@@ -2721,15 +2721,18 @@ function! s:controllerEdit(cmd,...)
if a:0 == 0
let controller = s:controller(1)
if rails#buffer().type_name() =~# '^view\%(-layout\|-partial\)\@!'
- let suffix .= '#'.expand('%:t:r')
+ let jump = '#'.expand('%:t:r')
+ else
+ let jump = ''
endif
else
- let controller = a:1
+ let controller = matchstr(a:1, '[^#!]*')
+ let jump = matchstr(a:1, '[#!].*')
endif
if rails#app().has_file("app/controllers/".controller."_controller.rb") || !rails#app().has_file("app/controllers/".controller.".rb")
let suffix = "_controller".suffix
endif
- return rails#buffer().open_command(a:cmd, controller, 'controller', {
+ return rails#buffer().open_command(a:cmd, controller . jump, 'controller', {
\ 'prefix': 'app/controllers/',
\ 'suffix': suffix})
endfunction

0 comments on commit eb8e977

Please sign in to comment.