[api] initial porting to rails 4 beta1