Leave sql to rails magic as much as possible