# skip validation

**URL:** <https://discuss.rubyonrails.org/t/skip-validation/13450>\
**Category:** rubyonrails-talk\
**Created:** [May 25, 2007, 3:06pm UTC](https://discuss.rubyonrails.org/t/skip-validation/13450 "2007-05-25T15:06:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Faisal\_N\_Jawdat](https://avatars.discourse-cdn.com/v4/letter/f/34f0e0/32.png) [@Faisal\_N\_Jawdat](https://discuss.rubyonrails.org/u/Faisal_N_Jawdat)\
**Post date:** [May 25, 2007, 3:06pm UTC](https://discuss.rubyonrails.org/t/skip-validation/13450/1 "2007-05-25T15:06:21Z")

</div>

:on =\> create

-faisal

---

<div class="post-metadata">

**Author:** ![Michael\_Latta](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@Michael\_Latta](https://discuss.rubyonrails.org/u/Michael_Latta)\
**Post date:** [May 25, 2007, 5:40pm UTC](https://discuss.rubyonrails.org/t/skip-validation/13450/2 "2007-05-25T17:40:08Z")

</div>

This does not sound right to me.

WHen you save a user object you should either have a password or not have one. If you allow the user to exist with no password then your validations should be done conditionally in your validate method. But, I would not allow a user to exist without a password, that is a bad security setup. Validations happen at the model level not the form level, so you are validating the entire user record not just the fields being changed by a form.

If I misunderstood your situation pleas include more detail.

Michael

---

<div class="post-metadata">

**Author:** ![GoodbyeJava](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@GoodbyeJava](https://discuss.rubyonrails.org/u/GoodbyeJava)\
**Post date:** [May 25, 2007, 7:15pm UTC](https://discuss.rubyonrails.org/t/skip-validation/13450/3 "2007-05-25T19:15:04Z")

</div>

First a more direct answer to your question:

ActiveRecord supplies validate\_on\_create and validate\_on\_update as separate methods from validate. If you really wanted validation of creation of objects, but not on update you could put your validation in validate\_on\_create.

However, it sounds like you have a fundamental misunderstanding of validation (as eluded to in a previous reply). If you are validating a user's password for presence and length then you should always perform that check.

class User \< ActiveRecord::Base &nbsp;&nbsp;validates\_presence\_of :username, :password &nbsp;&nbsp;validates\_length\_of :password, :minimum =\> 6

&nbsp;&nbsp;validate\_on\_create &nbsp;&nbsp;&nbsp;&nbsp;#put your create validations here &nbsp;&nbsp;end

&nbsp;&nbsp;validate\_on\_update &nbsp;&nbsp;&nbsp;&nbsp;#put your update validations here &nbsp;&nbsp;end end

It almost sounds like you are validating somewhere else besides the model. If you are doing that then....well don't. What happens if records are inserted or updated without going through your view or controller.

---

<div class="post-metadata">

**Author:** ![jetabe007](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/jetabe007/32/2469_2.png) [@jetabe007](https://discuss.rubyonrails.org/u/jetabe007)\
**Post date:** [May 26, 2007, 1:28pm UTC](https://discuss.rubyonrails.org/t/skip-validation/13450/4 "2007-05-26T13:28:32Z")

</div>

Hi from what i have understood: firstly u need to get a instance of the user you want to update @user = users.find( :first, :conditions =\> { :id =\> your id} ) now update the instance and call update on this instance the validations are already in the right place so no need to change them

cheers...
