0

I have this error and this is my code:

 params[:authorization][:contract_ids].each_with_index do |index, id|
      Authorization.find(id).update_column(value_solve: params[:authorization][:value_solve])
    end

This started with 0, and Authorization have id 1 and forward. How solve this? I tried many things but nothing don't worked =/

Elton Santos
  • 571
  • 6
  • 32

2 Answers2

0

I see, you are not even using index, just go straight with .each looping.

Try this one:

 params[:authorization][:contract_ids].each do |id|
      Authorization.find(id).update_column(value_solve: params[:authorization][:value_solve])
 end
7urkm3n
  • 6,054
  • 4
  • 29
  • 46
0

The answer this is:

      auth_params = params[:authorization]
auth_params[:contract_number].zip(auth_params[:value_solve].reject(&:blank?)).each do |contract_number, value_solve|
          Authorization.where(contract_number: contract_number).update_all(value_solve: value_solve, situation: 2)
      end

:D

Elton Santos
  • 571
  • 6
  • 32