# Validates\_presence\_of?

**URL:** <https://www.ruby-forum.com/t/validates-presence-of/88834>\
**Category:** Rails\
**Created:** [March 14, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/validates-presence-of/88834 "2007-03-14T21:22:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 14, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/validates-presence-of/88834/1 "2007-03-14T21:22:11Z")

</div>

I have a situation in which I would like it to be possible to create a  
user. But also allow an administrator to modify certain values  
associated with that user (username, email, privileges). I have  
created my own authentication system based on an example I found.

My problem is that currently I am validating the presence of all the  
fields in the table (for new user creation). What would be the best  
way to have it not worry about some fields (password and confirm for  
example) when modifying? I don’t want the admin to have access to  
user passwords.

Thanks,  
Glen

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 14, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/validates-presence-of/88834/2 "2007-03-14T21:32:13Z")

</div>

> I have a situation in which I would like it to be possible to create a  
> user. But also allow an administrator to modify certain values  
> associated with that user (username, email, privileges). I have  
> created my own authentication system based on an example I found.
> 
> My problem is that currently I am validating the presence of all the  
> fields in the table (for new user creation). What would be the best  
> way to have it not worry about some fields (password and confirm for  
> example) when modifying? I don’t want the admin to have access to  
> user passwords.

You can add “:on =\> :create” where :create can be :update as well… that  
lets you “split” up your validations…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 14, 2007, 9:34pm UTC](https://www.ruby-forum.com/t/validates-presence-of/88834/3 "2007-03-14T21:34:14Z")

</div>

Thanks, actually I saw that in the api but it didn’t click with me.
