javascript - AngularJS $resource sending out an extra "registration" hash? -


new angularjs here , have trouble getting $resource work. i've created factory , hardcoded $resource object backend needs in order create new plumber.

however, when call function, instead of passing params i've entered, creates 'sort of' duplicate content in form of registration hash, shown in hte backend of app (bolded below). it's exact duplicate of params. did come from???

the create() function called button in plumbers/new.html template

<button data-ng-click="create()">create</button>

where did hash come from???

new.js

angular.module('ngappapp') .controller('plumbersnewctrl', function ($scope, $window, $resource, plumbers) {  $scope.create = function(){   var test1 = new plumbers({     "business[email]": "superhero@super.com",     "business[password]": "123123",     "business[name]": "alice cullen",     "business[company]": "alice pty ltd",     "business[abn]": "12312312",     "business[contact_number]": "0421772800",     "business[address]": "118 glass street",     "business[suburb]": "essendon",     "business[postcode]": "3040",     "business[employees_number]": "8"   });    test1.$save(); };  });  angular.module('ngappapp') .factory('plumbers', function($resource){ return $resource('/businesses'); }); 

and response backend:

started post "/businesses" 127.0.0.1 @ 2013-08-26 20:40:27 +1000 processing businesses::registrationscontroller#create json parameters: {"business[email]"=>"superhero@super.com", "business[password]"=>"[filtered]", "business[name]"=>"alice cullen", "business[company]"=>"alice pty ltd", "business[abn]"=>"12312312", "business[contact_number]"=>"0421772800", "business[address]"=>"118 glass street", "business[suburb]"=>"essendon", "business[postcode]"=>"3040", "business[employees_number]"=>"8", "registration"=>{"business[email]"=>"superhero@super.com", "business[password]"=>"[filtered]", "business[name]"=>"alice cullen", "business[company]"=>"alice pty ltd", "business[abn]"=>"12312312", "business[contact_number]"=>"0421772800", "business[address]"=>"118 glass street", "business[suburb]"=>"essendon", "business[postcode]"=>"3040", "business[employees_number]"=>"8"}} warning: can't verify csrf token authenticity (0.1ms) begin transaction (0.0ms) rollback transaction completed 400 bad request in 6ms (views: 0.1ms | activerecord: 0.2ms)

edit:

logging test1 shows correct params without 'extra'

resource {business[email]: "superhero@super.com", business[password]: "123123",                                           business[name]: "alice cullen", business[company]: "alice pty ltd", business[abn]: "12312312" business[address]: "118 glass street" business[company]: "alice pty ltd" business[contact_number]: "0421772800" business[email]: "superhero@super.com" business[employees_number]: "8" business[name]: "alice cullen" business[password]: "123123" business[postcode]: "3040" business[suburb]: "essendon" 

it's not doubled. rails wrapping params inside of registrations parameter, see both, cause still lets through. i'm writing angularjs app on rails.

btw, why wrapping code that? if want wrap inside of hash need do:

business = {name: "name", blah:"blah"}


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -