Make an is_admin? method on your user.
def is_admin?
self.admin # Or how ever you figure out the person is an admin
end
In your validation:
validates_presence_of :email, :if => :is_admin?
That should do it.
On Wed, Jun 24, 2009 at 5:55 AM, Newb Newb
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
>
> Hi everyone,
> i have 20 fields in users table.
> in my admin profile module the admin can modify his infomation.
> but only 12 fields he can able to modify.
> for the users email field is not mandatory.but for admin email is a
> mandatory field.
> how can i use the validates_presence_of method under this requirement.
> pls help
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--
Christopher Warren
christopher.warren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
612.424.9880
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---