Fix compatibility with old ActiveRecord versions

I had some compatibility issues with Rails 3.2.17. These changes fixed the problems for me.