Ruby on rails 方法更新和错误未经允许的参数rails 4

Ruby on rails 方法更新和错误未经允许的参数rails 4,ruby-on-rails,angularjs,nested-attributes,strong-parameters,Ruby On Rails,Angularjs,Nested Attributes,Strong Parameters,rails 4和angularjs中的强参数有问题,在控制器内部的方法更新中,我收到以下错误: 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 不允许的参数:id、格式、客户 这是我发送的json:

rails 4和angularjs中的强参数有问题,在控制器内部的方法更新中,我收到以下错误:

未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 未允许的参数:id、客户id、创建时间、更新时间 不允许的参数:id、格式、客户

这是我发送的json:

    {
    "id"=>"52", 
    "CliERP"=>"C-00125", 
    "CliRazao"=>"CHOCOLANDIA COMERCIO DE CHOCOLATES LTDA.", 
    "CliCNPJ"=>"55946756000110", 
    "CliEmail"=>"contato@chocolandia.com.br", 
    "CliObs"=>"TESTE\nTESTE CHOCOMANIA 123456", 
    "enderecos_attributes"=>[
        {
            "id"=>52, 
            "cliente_id"=>52, 
            "EndTipo"=>"E", 
            "EndCEP"=>"78456441", 
            "EndLogradouro"=>"RUA IPIRANGA", 
            "EndNumero"=>"2500", 
            "EndBairro"=>"CENTRO", 
            "EndCidade"=>"PORTO ALEGRE", 
            "EndEstado"=>"RS", 
            "created_at"=>"2016-04-30T18:00:11.249Z", 
            "updated_at"=>"2016-04-30T18:00:11.249Z"
        }
    ], 
    "telefones_attributes"=>[
        {
            "id"=>3, 
            "cliente_id"=>52, 
            "TelTipo"=>"F", 
            "TelNumero"=>"7843257896", 
            "created_at"=>"2016-04-30T18:00:11.251Z", 
            "updated_at"=>"2016-04-30T18:00:11.251Z"
        }, 
        {
            "id"=>4, 
            "cliente_id"=>52, 
            "TelTipo"=>"F", 
            "TelNumero"=>"7845214563", 
            "created_at"=>"2016-04-30T18:00:11.254Z", 
            "updated_at"=>"2016-04-30T18:00:11.254Z"
        }, 
        {
            "id"=>5, 
            "cliente_id"=>52, 
            "TelTipo"=>"C", 
            "TelNumero"=>"78996568941", 
            "created_at"=>"2016-04-30T18:00:11.257Z", 
            "updated_at"=>"2016-04-30T18:00:11.257Z"
        }
    ], 
    "emails_attributes"=>[
        {
            "id"=>1, 
            "cliente_id"=>52, 
            "MailTipo"=>"E", 
            "MailEndereco"=>"financeiro@chocolandia.com.br", 
            "created_at"=>"2016-04-30T18:00:11.261Z", 
            "updated_at"=>"2016-04-30T18:00:11.261Z"
        }, 
        {
            "id"=>2, 
            "cliente_id"=>52, 
            "MailTipo"=>"E", 
            "MailEndereco"=>"cristina.presidente@chocolandia.com.br", 
            "created_at"=>"2016-04-30T18:00:11.275Z", 
            "updated_at"=>"2016-04-30T18:00:11.275Z"
        }, 
        {
            "id"=>3, 
            "cliente_id"=>52, 
            "MailTipo"=>"E", 
            "MailEndereco"=>"roberto.comercial@chocolandia.com.br", 
            "created_at"=>"2016-04-30T18:00:11.277Z", 
            "updated_at"=>"2016-04-30T18:00:11.277Z"
        }
    ]
}
这是我的控制器:

class ClientesController < ApplicationController
    def index
        @clientes = Cliente.all
    end

    def show        
        @clientes = Cliente.find(params[:id])
        @clientes.enderecos = Endereco.where("cliente_id = ?", params[:id])
        @clientes.telefones = Telefone.where("cliente_id = ?", params[:id])
        @clientes.emails = Email.where("cliente_id = ?", params[:id])
        #logger.debug "RETORNO => #{@clientes.inspect}"
    end

    def create
        @cliente = Cliente.new(cliente_params)

        respond_to do |format|
            if @cliente.save
                format.json { render :show, status: :created }
            else
                format.json { render json: @cliente.errors, status: :unprocessable_entity }
            end
        end
    end

    def update
        respond_to do |format|
            if @cliente.update(cliente_params)
                format.json { render :show, status: :ok }
            else
                format.json { render json: @cliente.errors, status: :unprocessable_entity }
            end
        end
    end

    def destroy
        @cliente.destroy
        respond_to do |format|
            format.json {head :no_content}
        end
    end

    private
    def cliente_params
        params.permit(:CliERP, :CliRazao, :CliCNPJ, :CliEmail, :CliObs, 
            enderecos_attributes: [:EndTipo, :EndLogradouro, :EndNumero, :EndBairro, :EndCidade, :EndCEP, :EndEstado],
            telefones_attributes: [:TelTipo, :TelNumero],
            emails_attributes: [:MailTipo, :MailEndereco])
    end
end
class ClientesController{@clientes.inspect}”
结束
def创建
@cliente=cliente.new(cliente_参数)
回应待办事项|格式|
如果@cliente.save
format.json{render:show,status::created}
其他的
format.json{render json:@cliente.errors,status::unprocessable_entity}
结束
结束
结束
def更新
回应待办事项|格式|
if@cliente.update(客户参数)
format.json{render:show,status::ok}
其他的
format.json{render json:@cliente.errors,status::unprocessable_entity}
结束
结束
结束
def销毁
@客户
回应待办事项|格式|
format.json{head:no_content}
结束
结束
私有的
def客户参数
参数许可证(:CliERP,:CliRazao,:CliCNPJ,:CliEmail,:CliObs,
endrecos_属性:[EndTipo,:EndLogradouro,:EndNumero,:EndBairro,:EndCidade,:EndCEP,:EndEstado],
telefones_属性:[:TelTipo,:TelNumero],
电子邮件\u属性:[:MailTipo,:MailEndereco])
结束
结束
编辑:这是我的模特的

cliente.rb

class Cliente < ActiveRecord::Base
    has_many :enderecos, autosave: true
    has_many :telefones, autosave: true
    has_many :emails, autosave: true
    has_many :pedido

    accepts_nested_attributes_for :enderecos
    accepts_nested_attributes_for :telefones
    accepts_nested_attributes_for :emails
end
class客户
endereco.rb

class Endereco < ActiveRecord::Base
    belongs_to :cliente
end
类Endereco email.rb

class Email < ActiveRecord::Base
    belongs_to :cliente
end
class电子邮件
电话电报

class Telefone < ActiveRecord::Base
    belongs_to :cliente
end
classtelefone
我想我的问题出在客户参数上
谢谢

活动记录嵌套属性

活动记录嵌套属性