Re: Protecting fields from being changed

gene tani
2007-10-14T05:14:22Z

On Oct 13, 9:03 pm, Luzzy
<luzer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> Hi all,
>
> I am familiar with attr_accessible.  But lately I have realised that
> it doesnt do exactly what I want it to do.
>
> Once a user is created on the system, I want to prevent the person
> from changing their username.
>
> I need username to be accessible on create... but after that I need it
> to be protected.
>
> Similarly - passwords need to be protected malicious form submits. I
> don''t want peope to be able to change their password in a sneaky
way
> when, say, they submit a form to change their address.
>
> Instead, passwords should only be changed after they submit a very
> paticular form, and after they confirm the change through email.
>
> Are there any ideas on how to lock down certain values in a model
> after its initial creation?
>
> thanks!

you could do a before_update, or try this: