Displaying 1 result from an estimated 1 matches for "readonlyattribut".
Did you mean:
readonlyattributes
2009 Mar 02
0
Implementing conditional read-only attributes of ActiveRecord objects
...is
consistent. This, however, requires that the readonly state is
determined on object _creation_ (or load time) and not only when
validation happens.
So the approach used in "attr_readonly" doesn''t work since it''s a
class method.
I could of course, do something like
ReadonlyAttributes = [:firstname, :lastname, :gender_id, :birthdate]
def is_readonly?(attr)
true if ReadonlyAttributes.include?(attr) and
self.passport_verified?
end
def validate
ReadonlyAttributes.each do |attr|
errors.add(attr, "You cannot change #{attr}!") if attr.changed?
end...