ActiveRecord support

It's a big commit, sorry bro.