So I want to automatically remove a model attribute when a specific other attribute of the same model changed.
I got a rails model named profile and it has a picture attribute containing an URL to an image in our image store. Additionally the model has a crop_data attribute containing information which part of the image to present to the user, which can be set by the user and defaults to profile.crop_data? # => false
If the profile.picture attribute changed or got removed/reset
profile.crop_data? # should return false
and be reset to default value in the database.
What is the cleanest way to achieve this? Unfortunately we are still running Rails 3.2.21.
Aucun commentaire:
Enregistrer un commentaire