I want to check if the attributes on the model have changed. I tried checking the values! = The value in the form before doing the save, but this code is really ugly and does not work well from time to time. Same thing with using update_column, which does not perform validation in my model class. If I use update_attributes without doing anything else, I cannot check when the field was updated from my understanding. From my web research on Qaru and other sites, it seems like using ActiveModel Dirty is the way to go.
I looked at this: http://api.rubyonrails.org/classes/ActiveModel/Dirty.html
I hope to use this to check if the logical flags on the model have changed after using update_attributes. I tried to perform a minimal implementation as described in the included link. I added the following to the ActiveRecord class:
include ActiveModel::Dirty
define_attribute_methods [:admin]
I tried adding three attributes that I wanted to track. I started with one attribute to see if I can make it work. When running the rspec test, I received the following error. As soon as I deleted the argument, I had no errors.
Exception encountered:
After I removed the argument, I decided to include similar methods in my model, using admin instead of a name. Other Rspec tests have violated the save method. However, I feel the problem is how I implement ActiveModel Dirty.
, , 3.2.8, 3.2.6 3.2.8. , , ActiveModel:: Dirty admin_changed? , .
- , , , . , , , Rails .
, . , , . , - .