# Validates\_presence\_of - only on edit

**URL:** <https://www.ruby-forum.com/t/validates-presence-of-only-on-edit/160103>\
**Category:** Rails\
**Created:** [February 11, 2009, 8:51pm UTC](https://www.ruby-forum.com/t/validates-presence-of-only-on-edit/160103 "2009-02-11T20:51:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [February 11, 2009, 8:51pm UTC](https://www.ruby-forum.com/t/validates-presence-of-only-on-edit/160103/1 "2009-02-11T20:51:00Z")

</div>

Ok so not sure if this is possible but it would help out a lot if it  
is. I am trying to put this validation on one of my forms

validates\_presence\_of :name, :state

however I only need this validation to run when they edit this form,  
not when they create it. is this possible, any suggestions would be  
greatly appreciated. thanks in advance.

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [February 11, 2009, 9:09pm UTC](https://www.ruby-forum.com/t/validates-presence-of-only-on-edit/160103/2 "2009-02-11T21:09:17Z")

</div>

> Ok so not sure if this is possible but it would help out a lot if it  
> is. I am trying to put this validation on one of my forms
> 
> validates\_presence\_of :name, :state
> 
> however I only need this validation to run when they edit this form,  
> not when they create it. is this possible, any suggestions would be  
> greatly appreciated. thanks in advance.

Check the docs… it’s in there.

# on - Specifies when this validation is active (default is :save,

other options :create, :update).

validates\_presence\_of :name, :state, :on =\> :update

-philip

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [February 12, 2009, 7:47am UTC](https://www.ruby-forum.com/t/validates-presence-of-only-on-edit/160103/3 "2009-02-12T07:47:46Z")

</div>

hey thanks that was the trick, much appreciated

---

<div class="post-metadata">

**Author:** ![perezda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@perezda](https://www.ruby-forum.com/u/perezda)\
**Post date:** [February 12, 2009, 7:48am UTC](https://www.ruby-forum.com/t/validates-presence-of-only-on-edit/160103/4 "2009-02-12T07:48:22Z")

</div>

hey thanks that was the trick, much appreciated
