How I solve this? update instead of update_all ?

Em segunda-feira, 18 de abril de 2016 15:21:46 UTC-3, Elton Santos escreveu:
>
> Someone can help me please? I posted on stackoverflow here:
>
>
> http://stackoverflow.com/questions/36694536/no-implicit-conversion-of-symbol-into-integer-a-error-still-no-solution-for-me
>
> My problem is this:
>
> def new
>     if params[:authorization].present?
>       @selected_ids = params[:authorization][:contract_ids]
>       @authorizations = Authorization.where("contract_number in (?)", 
> @selected_ids)
>       Authorization.where(id: 
> params[:authorization][:contract_ids]).update_all(value_solve: 
> params[:authorization][:value_solve], situation: 2)
>     end
>     @employee = Employee.search_cpf(params[:search_employee_by_cpf])
>     @refinancing = Refinancing.new
>
>
> Have no more errors, but dont save on my table authorization, and my query 
> is wrong. This is my console:
>
> Started GET 
> "/refinancings/new?utf8=%E2%9C%93&search_employee_by_cpf11111&authorization%5Bcontract_ids%5D%5B%5D=11&authorization%5Bvalue_solve%5D%5B%5D=89888&authorization%5Bvalue_solve%5D%5B%5D=&authorization%5Bvalue_solve%5D%5B%5D=&commit=Reserve"
>  for 127.0.0.1 at 2016-04-18 10:40:08 -0300Processing by 
> RefinancingsController#new as HTML
>   Parameters: {"utf8"=>"✓", "search_employee_by_cpf"=>"1111111111", 
> "authorization"=>{"contract_ids"=>["11"], "value_solve"=>["89888", "", ""]}, 
> "commit"=>"Reserve"}
>   SQL (0.2ms)  UPDATE "authorizations" SET "value_solve" = '---
> - ''89888''
> - ''''
> - ''''
> ', "situation" = 2 WHERE "authorizations"."id" = 11
>   Employee Load (0.2ms)  SELECT  "employees".* FROM "employees" INNER JOIN 
> "people" ON "people"."id" = "employees"."person_id" WHERE (people.cpf LIKE 
> '%02849112321%')  ORDER BY "employees"."id" ASC LIMIT 1
>   Person Load (0.1ms)  SELECT  "people".* FROM "people" WHERE "people"."id" = 
> ? LIMIT 1  [["id", 1]]
>   Authorization Load (0.2ms)  SELECT "authorizations".* FROM "authorizations" 
> WHERE (contract_number in ('11'))
>   Rendered refinancings/new.html.erb within layouts/application 
> (70.5ms)Completed 200 OK in 119ms (Views: 85.2ms | ActiveRecord: 1.4ms)
>
>
> How I said, I think that the error is because "authorizations".id = 11. I 
> haven't id 11, id 11 equal contract_number. The id was to be 1.
> Please, make more than 2 weeks that I try but nothing work =(
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/a7495d16-972a-446d-8a1d-02d370e46334%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to