refactor rails server API