ActiveRecord 4.0.0.beta1 support

@twobitlabs indicated they will look at official support for ActiveRecord 4.0 when it's out of beta, so this pull request is probably going to remain open until then.

Having this pull request here should make it easy for people looking for AR 4.0 beta support to find/try/fix/improve the code, so when AR 4.0 is out of beta we'll have solid support for it.