MyClass < ActiveRecord::Base
attr_protected :field
end
In script/console:
x = MyClass.find 1
# => field = "original"
x.field="blah"
# => "blah"
x.save
# => ...
x = MyClass.find 1
# => field = "original"
Why is there still a field=() method (even though it doesn't work when
saving the object), when I have set it to protected?
because that's not what attr_protected is supposed to do - it is only
supposed to stop the field getting updated when you do
object.update_attributes(...) and similar. why the save isn't working
for you is another issue.
because that's not what attr_protected is supposed to do - it is only
supposed to stop the field getting updated when you do
object.update_attributes(...) and similar. why the save isn't working
for you is another issue.
OK, so it is normal, that every field in the database has its own getter
and, method whether it is protected or not, right? Thanks.
Now I just redeclared the field=(str) method to be private. Would you
suggest this to be a clean way to "unset" the method?