How to get the original value of an attribute in Rails

前端 未结 4 1415
一生所求
一生所求 2020-12-23 20:17

is there a way to get the original value that an ActiveRecord attribute (=the value that was loaded from the database)?

I want something like this in an observer

4条回答
  •  渐次进展
    2020-12-23 20:49

    Take a look in rails documentation

    http://api.rubyonrails.org/classes/ActiveModel/Dirty.html

    Model.attribute_was return previous value :D

提交回复
热议问题