What callback can we use on search results, which allows us to add few more transient attributes to the search results apart from the database record
https://guides.rubyonrails.org/active_record_callbacks.html
CodePudding user response:
You can use after_find
as it will be called after record loaded from database.
The after_find callback will be called whenever Active Record loads a record from the database. after_find is called before after_initialize if both are defined.
https://guides.rubyonrails.org/active_record_callbacks.html#after-initialize-and-after-find