Hello There, Today I will discuss how to pass parameters in active record callback methods:
Models
In models write callback method in following style like
class Book < ApplicationRecord #==== Callbacks ========================================================== after_commit :do_something, on: :create after_commit -> { do_something('I am parameterize call') }, on: :destroy
private def do_something(params = nil) puts "params" endend
# here you can see there is a method named do_something is called with parameters.# if you delete a book then the output will be like:# I am parameterize callThanks!!