[api] initial porting to rails 4