I do not understand what I'm doing wrong. RoR project (with WebSocketRails), haml, angular and coffeescript layout. Angular does not save data.
Here is a fragment of the page (haml):
.form-group .col-xs-12 %label.control-label Имя: .col-xs-12 %input.form-control{'ng-model' => 'user_profile.first_name'} .form-group .col-xs-12 %label.control-label Фамилия: .col-xs-12 %input.form-control{'ng-model' => 'user_profile.last_name'} .form-group .col-xs-12 %label.control-label skype: .col-xs-12 %input.form-control{'ng-model' => 'user_profile.skype'} .button-group %button.button.btn.btn-cancel{'ng-click' => "cancel()"} Отмена %button.button.btn.btn-save{'ng-click' => 'save_user_profile()'} Сохранить In the appropriate controller, the profile saving method is described:
@personal.controller 'PersonalAccountCtrl', ['$scope', 'Logging', 'SmipeData', ($scope, Logging, SmipeData) -> $scope.save_user_profile = () -> SmipeData.save_user_profile() ] Which calls the class method:
@smipe.factory 'SmipeData', ['$http', '$rootScope', 'Logging', ($http, $rootScope, Logging) -> class SmipeData ... dispatcher = new WebSocketRails(websocket_url) ... save_user_profile: () -> dispatcher.trigger('smipe.edit', {user:user_profile}, save_user_profile_success, save_user_profile_failure) Here dispatcher is an instance of the WebSocketRails class (I connected it by setting the "WebSocketRails" gem). The smipe.edit itself is in turn a method in the controller:
def edit if current_user and message.has_key? :user if current_user.update_profile(message[:user]) @response[:success] = true @response[:user] = UserSerializer.new(current_user, root: false) else @response[:success] = false end end trigger_success @response end Then the success callback from the same SmipeData is executed:
@smipe.factory 'SmipeData', ['$http', '$rootScope', 'Logging', ($http, $rootScope, Logging) -> class SmipeData ... save_user_profile_success = (data) -> if data.success $rootScope.$apply -> user_profile = data.user else console.log "save_user_profile error" Actually everything. But the data in the database did not appear. What am I doing wrong?
It seems like this line should save to the database:
$rootScope.$apply -> user_profile = data.user But she does not save.
Who used Angular and WebSocket'y please tell me how to save to the database. Or tell me where to read about angular and websocket.
PS PostgreSQL database, and it is working, the configs are correct, users are created by devis. But I do not understand how to change their data.