Quickie: Rails migrations shortcut

Posted by fcoury, Sat Feb 07 18:57:00 UTC 2009

Silly small trick to make editing new migrations easier on a Mac environment.

Just add this little function to your .profile file:

function mig {
  mate `script/generate migration $1|tail -n1|sed 's/.*create  //'`
}

And then just run:

$ mig AddSomethingToSomewhere

From within your Rails application root folder.

This will execute the migration and open TextMate with the generated rb file right away. Cool.

For this and more tips for your Mac shell, take a look at my profile on my dotfiles repo on GitHub: http://github.com/fcoury/dotfiles

Please share your own tricks on the comments below.

Filed Under: Mac OS X Ruby | Tags:

Comments

Clicky Web Analytics