0 votes
in Ruby by
In the model User you have the code shown below. When saving the model and model.is_admin is set to true, which callback will be called?

before_save :encrypt_data, unless: ->(model) { model.is_admin }

after_save :clear_cache, if: ->(model) { model.is_admin }

before_destroy :notify_admin_users, if: ->(model) { model.is_admin }

a. encrypt_data

b. clear_cache

c. notify_admin_users

d. None of these callbacks will be called when is_admin is true.

1 Answer

0 votes
by

In the model User you have the code shown below. When saving the model and model.is_admin is set to true, which callback will be called?

before_save :encrypt_data, unless: ->(model) { model.is_admin }

after_save :clear_cache, if: ->(model) { model.is_admin }

before_destroy :notify_admin_users, if: ->(model) { model.is_admin }

Correct answer is :-  encrypt_data

Related questions

0 votes
asked Sep 3, 2022 in Ruby by DavidAnderson
0 votes
asked Sep 3, 2022 in Ruby by DavidAnderson
...