8

我喜欢 Rails.vim,但在某些项目中使用它时遇到问题。我的一个应用程序中有两个控制器位置:

app/controllers
app/controllers/v1/api

我可以以某种方式配置(可能在 config/rails.vim 中?)这个额外的路径吗?我想同时使用它们。

我可以像这样手动导航:

:Rcontroller v1/api/messages_controller.rb

但是这个控制器的 :Rmodel 不起作用,它会尝试跳转到 models/v1/api/model.rb

4

1 回答 1

1

This isn't tied into the rails.vim add-on, but you can add an additional command to do this for you. I believe this would be far easier than trying to modify the rails.vim source.

I actually wrote a blog post about something similar. For your purposes, you'd want to put something like this in your vimrc:

command -nargs=? RcontrollerApi e \path\to\your\project\app\controllers\v1\api\<args>_controller.rb

You could then call it like this:

:RcontrollerApi messages

You wouldn't have the extra rails.vim sweetness that goes along with the native functionality, though (Like typing :Rcontroller in a view to automatically go to that file).

Here's an idea that may (or may not) work. I don't believe it will allow you to access the aforementioned functionality but it very well may point you in the right direction.

command -nargs=? RcontrollerApi Rcontroller v1/api/<args>_controller.rb
于 2011-12-07T22:29:07.963 回答