Ruby on rails Rails-AJAX请求-未经允许的参数,即使允许用于数组值

Ruby on rails Rails-AJAX请求-未经允许的参数,即使允许用于数组值,ruby-on-rails,ajax,coffeescript,Ruby On Rails,Ajax,Coffeescript,我正在尝试在更新特定选择时发送修补程序请求 我的CoffeeScript代码是: $(document).on 'change', '#mailchimp_list_select', ()-> mailchimp_list_to_automatically_subscribe_people = $('#mailchimp_list_select').val() branch_id = $('#branch_id').val() $.ajax '/branches/'

我正在尝试在更新特定选择时发送修补程序请求

我的CoffeeScript代码是:

$(document).on 'change', '#mailchimp_list_select', ()->
    mailchimp_list_to_automatically_subscribe_people = $('#mailchimp_list_select').val()
    branch_id = $('#branch_id').val()
    $.ajax '/branches/'+branch_id+'.json',
        type: 'PATCH'
        data: {branch : {mailchimp_list_to_automatically_subscribe_people : mailchimp_list_to_automatically_subscribe_people}}
        dataType: 'text'
        error: (jqXHR, textStatus, errorThrown) ->
            $('body').append "AJAX Error: #{textStatus}"
        success: (data, textStatus, jqXHR) ->
我的控制器是

class BranchesController < ApplicationController
before_action :authenticate_user!
before_action :set_branch, only: [:show, :edit, :update]
respond_to :html, :xml, :json

def show
    respond_with(@branch)
end

def new
    @branch = Branch.new
    respond_with(@branch)
end

def edit
end

def update
    if @branch.update(branch_params)
        render nothing: true, status: :ok
        #CacheMailchimpListsJob.perform_later @branch.id
    else
        render nothing: true, status: :bad_request
    end
end

private
    def set_branch
        @branch = Branch.find(params[:id])
    end

    def branch_params
        params.require(:branch).permit(:mailchimp_list_to_automatically_subscribe_people, :name, :city, :country, :currency_id, :send_receipt, :address_line_1, :address_line_2, :address_line_3, :email, :legal_details, :legal_details_2, :custom_receipt_number, :mailchimp_api_key)
    end

    def cross_check_branch
        if @branch.id != session[:branch_id]
            redirect_to_root_path
        end
    end
当我调整发送到此的JSON时:

data: {mailchimp_list_to_automatically_subscribe_people : mailchimp_list_to_automatically_subscribe_people}
我得到这个错误:

ActionController::ParameterMissing - param is missing or the value is empty: branch:

我做错了什么?

错误是参数
mailchimp\u list\u to\u automatically\u subscribe\u people
作为一个数组接收值,需要明确允许,就像
mailchimp\u list\u to\u automatically\u subscribe\u people[]一样。您是否检查了服务器控制台中到达的参数?
参数:{“branch”=>{“mailchimp_list_to_automatically_subscribe_people”=>[“4977036871”],“id”=>“1”}
这些是arriveSee的参数,您需要使用
permit(mailchimp_list_to_to_automatically_subscribe_people:[])允许数组
)你完全正确!
ActionController::ParameterMissing - param is missing or the value is empty: branch: