Unpermitted parameters

1

Good day, my problem arises since I am trying to get a hash array inside another hash array, when doing this I get the message:

  

Unpermitted parameters: id, amount_ads

in the definition of the parameters I have the following:

    def payroll_params
        params.permit( 
          payroll: [
            :id, :employee_id, :week_id, :department_id, :dias_trabajados,
            :dias_vacaciones, :faltas, :total_percepciones, :total_retenciones,
            :total_sueldo_bruto, :total_sueldo_neto, :sueldo_fiscal, :pago_impuesto,
            :pago_eps, :tipo_pago_fiscal, :tipo_pago_eps, :created_by, :updated_by,
            :employee_wd_attributes=>[:id,:jueves, :viernes, :sabado, :domingo, :lunes, :martes, :miercoles],
            :employee_wad_attributes=>[:id=>[],:importe_ads=>[]]
          ]
        )
    end 

The problem is about: employee_wad_attributes, I attach the summary request to an element of the payroll hash:

And here what marks the Log:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"/IV+a8UngslZ/VXcCmBmG8ndKhzfFLH6NhyqmZ4NctliqP2QA3PLPF2GDP25zLpIpqIRU7kSPlermfhhZ7KuwA==", "payroll"=>[{"id"=>"44", "week_id"=>"39", "department_id"=>"2", "employee_id"=>"1", "employee_wd_attributes"=>{"id"=>"10", "jueves"=>"1", "viernes"=>"0", "sabado"=>"0", "domingo"=>"0", "lunes"=>"0", "martes"=>"0", "miercoles"=>"0"}, "dias_trabajados"=>"0.0", "dias_vacaciones"=>"0", "faltas"=>"0", "total_sueldo_bruto"=>"0.0", "employee_wad_attributes"=>[{"id"=>"1", "importe_ads"=>"3"}, {"id"=>"2", "importe_ads"=>"3"}, {"id"=>"3", "importe_ads"=>"0"}, {"id"=>"4", "importe_ads"=>"0"}, {"id"=>"5", "importe_ads"=>"0"}, {"id"=>"6", "importe_ads"=>"0"}, {"id"=>"7", "importe_ads"=>"0"}, {"id"=>"8", "importe_ads"=>"0"}, {"id"=>"9", "importe_ads"=>"0"}, {"id"=>"10", "importe_ads"=>"0"}, {"id"=>"11", "importe_ads"=>"0"}, {"id"=>"12", "importe_ads"=>"0"}, {"id"=>"13", "importe_ads"=>"0"}], "total_percepciones"=>"0.0", "total_retenciones"=>"0.0", "sueldo_fiscal"=>"0.0", "total_sueldo_neto"=>"2"}, {"id"=>"45", "week_id"=>"39", "department_id"=>"2", "employee_id"=>"2", "employee_wd_attributes"=>{"id"=>"11", "jueves"=>"1", "viernes"=>"0", "sabado"=>"0", "domingo"=>"0", "lunes"=>"0", "martes"=>"0", "miercoles"=>"0"}, "dias_trabajados"=>"0.0", "dias_vacaciones"=>"0", "faltas"=>"0", "total_sueldo_bruto"=>"0.0", "employee_wad_attributes"=>[{"id"=>"1", "importe_ads"=>"3"}, {"id"=>"2", "importe_ads"=>"3"}, {"id"=>"3", "importe_ads"=>"0"}, {"id"=>"4", "importe_ads"=>"0"}, {"id"=>"5", "importe_ads"=>"0"}, {"id"=>"6", "importe_ads"=>"0"}, {"id"=>"7", "importe_ads"=>"0"}, {"id"=>"8", "importe_ads"=>"0"}, {"id"=>"9", "importe_ads"=>"0"}, {"id"=>"10", "importe_ads"=>"0"}, {"id"=>"11", "importe_ads"=>"0"}, {"id"=>"12", "importe_ads"=>"0"}, {"id"=>"13", "importe_ads"=>"0"}], "total_percepciones"=>"0.0", "total_retenciones"=>"0.0", "sueldo_fiscal"=>"0.0", "total_sueldo_neto"=>"2"}, {"id"=>"46", "week_id"=>"39", "department_id"=>"2", "employee_id"=>"3", "employee_wd_attributes"=>{"id"=>"12", "jueves"=>"1", "viernes"=>"0", "sabado"=>"0", "domingo"=>"0", "lunes"=>"0", "martes"=>"0", "miercoles"=>"0"}, "dias_trabajados"=>"0.0", "dias_vacaciones"=>"0", "faltas"=>"0", "total_sueldo_bruto"=>"0.0", "employee_wad_attributes"=>[{"id"=>"1", "importe_ads"=>"3"}, {"id"=>"2", "importe_ads"=>"3"}, {"id"=>"3", "importe_ads"=>"0"}, {"id"=>"4", "importe_ads"=>"0"}, {"id"=>"5", "importe_ads"=>"0"}, {"id"=>"6", "importe_ads"=>"0"}, {"id"=>"7", "importe_ads"=>"0"}, {"id"=>"8", "importe_ads"=>"0"}, {"id"=>"9", "importe_ads"=>"0"}, {"id"=>"10", "importe_ads"=>"0"}, {"id"=>"11", "importe_ads"=>"0"}, {"id"=>"12", "importe_ads"=>"0"}, {"id"=>"13", "importe_ads"=>"0"}], "total_percepciones"=>"0.0", "total_retenciones"=>"0.0", "sueldo_fiscal"=>"0.0", "total_sueldo_neto"=>"2"}], "commit"=>"guardar", "method"=>"post", "remote"=>"true", "company_id"=>"1", "week_id"=>"39"}
 Unpermitted parameters: id, importe_ads (muchas veces)
 Unpermitted parameters: utf8, authenticity_token, commit, method, remote, company_id, week_id

I thank you for your help and time in advance.

    
asked by Daniel Romero 30.05.2017 в 20:20
source

2 answers

2

The error is caused because, when using =>[] in this line

:employee_wad_attributes=>[:id=>[],:importe_ads=>[]]

You are indicating that both :id and :importe_ads are groupers, that is, they have another set of keys, which is incorrect.

Therefore, you should simply indicate the keys that are allowed within that array:

:employee_wad_attributes=>[:id, :importe_ads]

Considering the above, this would be the method payroll_params :

def payroll_params
  params.permit( 
    payroll: [
      :id, :employee_id, :week_id, :department_id, :dias_trabajados,
      :dias_vacaciones, :faltas, :total_percepciones, :total_retenciones,
      :total_sueldo_bruto, :total_sueldo_neto, :sueldo_fiscal, :pago_impuesto,
      :pago_eps, :tipo_pago_fiscal, :tipo_pago_eps, :created_by, :updated_by,
      :employee_wd_attributes=>[:id,:jueves, :viernes, :sabado, :domingo, :lunes, :martes, :miercoles],
      :employee_wad_attributes=>[:id,:importe_ads]
    ]
  )
end
    
answered by 30.05.2017 / 22:20
source
0

The problem should be that you are trying to create a Hash for :employee_wad_attributes , but you are using [] (which is to create fixes)

:employee_wad_attributes => [ :id => [], :importe_ads => [] ]

Try as follows:

:employee_wad_attributes => { :id => [], :importe_ads => [] }
    
answered by 30.05.2017 в 21:24