Closed smlabonia closed 2 years ago
Hi,
Use this code:
BEFORE SAVE
@done_ratio_update = status_id==7 && !new_record? && User.current.id != @issue.assigned_to_id
AFTER SAVE
if @done_ratio_update
@issue.update_columns(done_ratio: 40)
@issue.parent.update({:status_id=>2})
end
I have the next scenario:
Script
if !self.new_record? if @issue.status_id == 7 if !(User.current.id == @issue.assigned_to_id) @issue.done_ratio = 40 @issue.status_id = 2 #En curso end end end
When the issue status is "Waiting for response", and the author make some changes, the issue will change her status to "In process".
I configured to done_ratio depends on statuses, and when it happen i get the next error:
Started PATCH "/issues/14" for 10.21.253.70 at 2020-04-21 08:36:04 -0300 Processing by IssuesController#update as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"RyvxWtwoPaN2vhXYB/Lyhi3GVeSV1R6wV2Y+JF2gxi3p082WSIi7R8PQvN3eF4zKquP4UgfHFoLLhhj2g1/mfw==", "issue"=>{"notes"=>"
test
\r\n", "lock_version"=>"7"}, "last_journal_id"=>"44", "commit"=>"Aceptar", "next_issue_id"=>"13", "issue_position"=>"1", "issue_count"=>"3", "id"=>"14"} Current user: test (id=471) = Running shared code for Issue (#14) "Requerimiento #14: test" = Finished running shared code for Issue (#14) "Requerimiento #14: test" = Running before_save custom workflows for Issue (#14) "Requerimiento #14: test" == Running before_save custom workflow " Esperando respuesta -> En curso" = Finished running before_save custom workflows for Issue (#14) "Requerimiento #14: test" Completed 500 Internal Server Error in 45ms (ActiveRecord: 11.5ms)ActiveRecord::NotNullViolation (Mysql2::Error: Column 'done_ratio' cannot be null: UPDATE
issues
SETstatus_id
= 2,done_ratio
= NULL,updated_on
= '2020-04-21 08:36:04',lock_version
= 8 WHEREissues
.id
= 14 ANDissues
.lock_version
= 7):