Rewrote huge bits the AR adapter to make it compatible w/ recent Rails version.