Ruby on Rails Tuesday, April 19, 2016

It is almost finishing! I believe. Look:

Processing by RefinancingsController#new as HTML
  Parameters: {"utf8"=>"✓", "search_employee_by_cpf"=>"11111111111", "authorization"=>{"contract_number"=>["11", "33"], "value_solve"=>["43343", "", "45454", ""]}, "commit"=>"Reserve"}
  SQL (91.9ms)  UPDATE "authorizations" SET "value_solve" = '43343', "situation" = 2 WHERE "authorizations"."contract_number" = ?  [["contract_number", "11"]]
  SQL (87.0ms)  UPDATE "authorizations" SET "value_solve" = '', "situation" = 2 WHERE "authorizations"."contract_number" = ?  [["contract_number", "33"]]

The problem is because take just first element, this is the code:

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

I just split in parts 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b42d0ff0-5d84-4e5e-8cb0-09dc7b7a5144%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment