Updated to support ActiveRecord 4.1