Fix inner join issue after upgrade rails version