Adding Script Binding / Creating Migration

I am making my Rails dev from xterm and vim.

It becomes awkward for me to work script/generate migration do_whatever, and then it is wasted through db/migratetrying to perform a tab before until 20091015235018_do_whateverthere are 5 other migrations with similar timestamps.

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

I would rather not crack the Rails kernel in / usr / lib, since I work from several systems and see that I want to create many such hooks. However, in reality it does not look like a plugin worthy.

There are many easy ways to get the name of the generated file, but I'm not sure how to simply connect it to the generation. What do you think?

+3
source share
2 answers

The best option with vim is to use rails.vim and enter :Rmigration do<TAB> It ignores the timestamp ...

You can also create and edit a migration at a time by typing :Rgenerate migration ...

+5
source

I just sent a Rails patch to add the -editor option only for this case, which you could include in any version of Rails you are using now. If you do not specify which editor you want, it tries to use EDITOR

+1
source

Source: https://habr.com/ru/post/1720243/


All Articles