I have a factory that exposes a create() function which uses $http.post() underneath. For some reason when it is called from an ng-click the request is being formatted as HTML. All of the params are where I want them to be, but Rails is processing the request as HTML.
The factory:
orizabaServices.factory('requestTypeFactory', ["$http", function($http){
var urlBase = '/request_types';
var requestTypeFactory = {};
requestTypeFactory.create = function(params){
data = {};
data.authenticity_token = $("meta[name='csrf-token']").attr("content");
data.request_type = params;
return $http.post(urlBase, data)
};
return requestTypeFactory;
}
])
The Error:
Started POST "/request_types" for 127.0.0.1 at 2014-08-01 17:10:00 +0000
Processing by RequestTypesController#create as HTML