Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I write multiple condition in after_create callbacks

I have a method in model that calls after create

after_create :generate_insurer_recovery_invoice, if: :insurance_recovery_batch?

How should I write another condition within this callback?

like image 229
Anand Jose Avatar asked Mar 10 '16 07:03

Anand Jose


1 Answers

You can also do this for a shorter readable version

after_save :update_offices_people_count if: -> {office_id_changed? || trashed_changed?}

P.S: -> is a shorthand version of writing lambda.

like image 134
Oluwayetty Avatar answered Sep 20 '22 10:09

Oluwayetty