Adding a hook to script/generate migration
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?
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 ...
I just submitted a patch to Rails to add an --editor option for just this case, which you could backport into whatever version of Rails you're using now. If you don't specify which editor you want it tries to use EDITOR
精彩评论