SSH Tunnels into Production Rails Database

Today I needed to access a production database for my Rails app directly using a GUI application on my mac, so I figured out that this can be done by creating an SSH tunnel like so:

ssh -Ng -L <local-port>:<remote-host>:<remote-port> <user>@<remote-host>
ssh -Ng -L 3307: adam@

And then, in your Rails app, update the database.yml as if you were connecting to a local database, but specify the proper database name.

  adapter: mysql2
  database: myapp_production
  port: 3307
  username: root
  password: secret
  encoding: utf8