Lighthouse has a new layout.
Prefer the old one? Return to the old layout,
and switch back any time from the link at the top of each page.
This project is archived and is in readonly mode.
attr_writeonce in AR models
#6505
I've spent a while looking for "write once" functionality in
Active Record, but it seems there's anything like that at the
moment. I'd expect that attr_writeonce allows to change the
attribute from nil to a value (exactly once). It's similar to
attr_readonly but it works for persisted records. Do you think it's
useful? I can try to prepare a patch if there's a chance that it
gets merged to Rails.
Method attr_readonly seems to be kind of "badly named". It
actually allows to write a "readonly" attribute, but only when
creating the record. I think it'd better to use something like
attr_writeonce :title, :on => :create
IMO attr_readonly shouldn't allow to change the attribute at
all.