Re: Protecting fields from being changed

gene tani
2007-10-14T14:28:01Z

On Oct 14, 7:19 am, gene tani
<gene.t...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> On Oct 14, 12:45 am, Luzzy
<luzer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > with before_update
>
> > is the idea that i check the submitted fields and throw an exception
> > if a protected field is given for an existing record?
>
> > is there a clean way to do this already explored?
>
> I haven''t tested this, but i think for the fields /columns you
want
> write-once, you just return false/nil.
>
> Also, there''s this, and attr_readonly, but I haven''t
figured out how
> to use
it:http://constancy.rubyforge.org/http://dev.rubyonrails.org/ticket/6896

BTW, this is a pretty common requirement, dozens of blogs.  Search for
"read-only", "write-once", "write-protected"
"constant" fields/
columns/ objects/models etc.