rails: refactoring angular ctrl