views:

154

answers:

1

I do my Rails dev from xterm and in vim.

I'm getting sick of running script/generate migration do_whatever, then trawling through db/migrate trying to tab-complete to 20091015235018_do_whatever when there's 5 other migrations with similar timestamps.

What's the best way to add a hook to open the generated migration in vim?

I'd rather not hack into Rails' core in /usr/lib as I work from several systems and can see myself wanting to create numerous such hooks. However, it doesn't really seem plugin worthy.

There are lots of simple ways to get the name of the generated file, but I'm not sure how to cleanly hook it into the generation. What do you think?

+2  A: 

A better option with vim is to use rails.vim and type :Rmigration do<TAB> It ignores the timestamp ...

You can also create and edit a migration in one go by typing :Rgenerate migration ...

Sam Saffron
Thanks, I've got rails.vim installed and was using it simply for the better syntax highlighting. Good to know about :Rmigration! Will be useful, but still can't figure out how to create and open a migration in one step even with rails.vim.
nfm
You can use :Rgenerate for that ...
Sam Saffron
@nfm make sure you use it for navigation as well ... :Rmodel will take you to a model, :Rview to a view and so on ... rails.vim is one massively useful plugin ...
Sam Saffron
Thanks again :) I had tried :Rscript generate migration! Doh.
nfm