Rails 4 head compat

This includes commits from the previous Rails 4 RC1 PR, and a change to lib/acts_as_tenant/model_extensions.rb to fix errors in Rails master head. This will break Rails 3 usage, so we'll either want to add logic to detect the Rails version or handle it with a separate branch or gem version.

I only use acts_as_tenant with Rails 4, but would be happy to make the gem support both 3 and 4.