Rails 3 check if attribute changed

前端 未结 5 713
渐次进展
渐次进展 2020-11-29 17:53

Need to check if a block of attributes has changed before update in Rails 3.

street1, street2, city, state, zipcode

I know I could use something like

5条回答
  •  野性不改
    2020-11-29 18:08

    Check out ActiveModel::Dirty (available on all models by default). The documentation is really good, but it lets you do things such as:

    @user.street1_changed? # => true/false
    

提交回复
热议问题