I have a simple service which I'm using to POST data to a Rails controller.
My service looks something like this:
app.service('autoRulesService', function($http) { return({ createRule: createRule }); function createRule() { var request = $http({ method: 'POST', url: '/rules.json', data: { one: 'two } }); return request.then(handleSuccess, handleError); } function handleSuccess() { // body omitted... } function handleError() { // body omitted... } }); I use that service in my controller in a pretty standard way:
$scope.saveRule = function() { rulesService.createRule().then(function() { // do stuff... }); } The problem is that I get a weird unwanted key in my parameters when I inspect the sent data in the Rails log. Where is the "rule" parameter coming from?
Processing by AutoAnalysis::RulesController#create as JSON Parameters: {"one"=>"two", "rule"=>{}} It doesn't appear in the request payload (as inspected in Chrome Dev tools)

and my controller action is pretty standard (there's no before filters either):
class RulesController < ApplicationController def create # NOTE: I'm referencing an :auto_analysis_rule parameter here because # that's my desired param key name. It doesn't exist in the request # as shown here. render json: Rule.create(params[:auto_analysis_rule]) end end and I can't find any mention of $http inferring a root JSON key from the URL or anything in the docs.
Where is the "rule" param key coming from?