Is it possible to find out what exactly has changed with the help of an observer in a ruby ​​on rails?

I need to send an email notification when the price of the product changes. Is it possible to do this with help ActiveRecord::Observeror do I need to use the programming logic in the edit form?

+3
source share
1 answer

You can use Dirty Objects to achieve this, in this particular case you will have something similar in your observer.

FooMailer.deliver_alert(foo) if foo.price_changed?

: " ". save prince_changed?.

, .

+5

Source: https://habr.com/ru/post/1755788/


All Articles