My requirement is that I want an object (tee) to update if there have not been rounds played on it. If there have been rounds played on it then I want the object (tee) to archive (active attribute set to false) and the updates to be applied to a clone of the object.
My first thought was that I would overwrite the update method in the Tee model like so and have a private method that handles the archive, clone and change:
def update
if(self.rounds.count == 0)
super
else
#archive, clone and apply changes
archive_clone_and_change
return false
end
end
This feels dirty though because I am returning a false on a successful archive update. It also is going to get tricky when I try to apply the changes in the archive_clone_and_change method.
Should I be doing this in the controller instead of the method or does my approach make sense?
Model vs. Controller decisions, they can get subjective, but I would to it in the controller. It’s really logic being applied to the model, not directly related to the model itself.