You should be able to do this:
validates_presence_of :name, :email, :on => :create
validates_presence_of :password, :password_confirmation, :on
=> :update
This should make it so that they only get called as you specified.
On May 4, 8:44 am, "John McAuley"
<johnmcau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello Everyone,
>
> I have a User model which uses validation helpers as follows:
>
> Model User
> 1) validates_presence_of :name, :email
> 2) validates_presence_of :password, :password_confirmation,
>
> When the user is created by the administrator, I want the first validation
> to be triggered (1). But when the user is updated, (ie the password added
> by the user on login), I want the second validation to be triggered (2).
So
> on creation the administrator is obliged to enter name and email, but when
> the user logs in for the first time, they are obliged to change their
> password. I am using active record and would like to stick to this mode of
> use if possible. The other option is to create two models, one for update
> and one for create but it seems a little superfluous. Has anyone any
ideas?
>
> Thanks,
>
> j
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---