[api] replace rails 2 code with rails 4 code