Ruby on Rails
Wednesday, April 20, 2016
update instead of update_all, is it?
Em segunda-feira, 18 de abril de 2016 15:21:46 UTC-3, Elton Santos escreveu:
-- 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: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.newHave 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_ for 127.0.0.1 at 2016-04-18 10:40:08 -0300 Processing by RefinancingsController#new as HTML Parameters: {"utf8"=>"✓", "search_employee_by_cpf"=>"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" 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 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/bda59217-52c7-4f2e-9986-62d91af08d61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment