Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 730
nfm Avatar asked Jun 27 '26 01:06

nfm


1 Answers

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 ...

like image 104
Sam Saffron Avatar answered Jun 29 '26 21:06

Sam Saffron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!