Hello, After a model has been saved I want to prevent some of it's fields from being updated. I was going to do this by overriding validate_on_update but I don't know how to access the old value to compare it to the new value. Cheers, Ewan
ewanmcdougall@googlemail.com wrote:
Hello, After a model has been saved I want to prevent some of it's fields from being updated. I was going to do this by overriding validate_on_update but I don't know how to access the old value to compare it to the new value. Cheers, Ewan
How about overriding the setter methods for those fields you want to lock. Something like...
def title=(t) self[:title] = t if self.new_record? end
Hello Jon, Thanks for the reply. I made the attribute read only doing
attr_readonly :title
Ewan