Code from the Ryan Bigg's (@ryanbigg) Multitenancy with Rails Book http://leanpub.com/multi-tenancy-rails