Last Updated: September 09, 2019
· aalvarado

Open last generated migration easily in your editor

Sometimes when generating a migration we need to look for it on the db folder and autocompleting the migration name.

This skips that and opens the latest migration in the db/migrate folder:

ls db/migrate/* | tail -n1 | xargs $EDITOR

you could create it as an alias:

alias last_migration='ls db/migrate/* | tail -n1 | xargs $EDITOR'

And use it like:

$ rails generate migration add_new_table
$ last_migration


3 Responses
Add your response

This only opens things in macvim. You should change it to use $EDITOR.

over 1 year ago ·

:O agreed.thanks for the tip

over 1 year ago ·

Def enjoy. Thanks!

over 1 year ago ·