Rails MySQL gem and OSX 10.5 Leopard MySQL 64 bit compile flag

I recently reinstalled mysql on my Macbook under OSX 10.5 Leopard and used the 64 bit MySQL (hey, Leopard is 64 bit! Why not?).

Anyhow, when I went to using rails again, mongrel_rails start kept throwing a whine on the fact that the old mysql gem (2.7) was 32 bit.

Found this after removing the old gem to get it working with 64 bit. Definitely not trivial to figure out:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

(Props to Kabisa ICT (dead link) in NL for posting this as it seems a lot of people were looking for the answer to this one from a google)