Replace snippet of sql with arel.