# Disable validation on edit

**URL:** <https://www.ruby-forum.com/t/disable-validation-on-edit/151871>\
**Category:** Rails\
**Created:** [October 27, 2008, 9:56am UTC](https://www.ruby-forum.com/t/disable-validation-on-edit/151871 "2008-10-27T09:56:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dharmdip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@dharmdip](https://www.ruby-forum.com/u/dharmdip)\
**Post date:** [October 27, 2008, 9:56am UTC](https://www.ruby-forum.com/t/disable-validation-on-edit/151871/1 "2008-10-27T09:56:45Z")

</div>

Hi all

I want to disable validation when i m calling the edit method. The  
reason y i want to do this is that i m allowing only certain fields to  
be edited. I dont want to pass hidden values.

Is there any method to disable validation when i call a certain method?

Thanks

---

<div class="post-metadata">

**Author:** ![dharmdip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@dharmdip](https://www.ruby-forum.com/u/dharmdip)\
**Post date:** [October 27, 2008, 10:18am UTC](https://www.ruby-forum.com/t/disable-validation-on-edit/151871/2 "2008-10-27T10:18:17Z")

</div>

On Oct 27, 8:56 am, Dharmdip R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi all
> 
> I want to disable validation when i m calling the edit method. The  
> reason y i want to do this is that i m allowing only certain fields to  
> be edited. I dont want to pass hidden values.
> 
> Is there any method to disable validation when i call a certain method?

You can do pretty much what you want with some combination of  
the :if/:unless options on validations and the :on option (method  
there refers to create/save/update - it has nothing to do with a  
controller method).  
Or just call save(false) from your controller if you don’t want any  
validations to run.

Fred

---

<div class="post-metadata">

**Author:** ![dharmdip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@dharmdip](https://www.ruby-forum.com/u/dharmdip)\
**Post date:** [October 27, 2008, 10:34am UTC](https://www.ruby-forum.com/t/disable-validation-on-edit/151871/3 "2008-10-27T10:34:40Z")

</div>

Hi

Thanks for your reply …My actual problem is that i m calling .save  
function from 2 different methods but in one method i want to validate  
and from the other i dont want to. Both uses the same model and the  
method is same. But the controller is different.

Hope you understood my exact problem

Thanks

---

<div class="post-metadata">

**Author:** ![dharmdip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@dharmdip](https://www.ruby-forum.com/u/dharmdip)\
**Post date:** [October 27, 2008, 10:48am UTC](https://www.ruby-forum.com/t/disable-validation-on-edit/151871/4 "2008-10-27T10:48:47Z")

</div>

you can either use update for edit or call save(false) to avoid all  
validations.

On Mon, Oct 27, 2008 at 5:34 PM, Dharmdip R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## Thanks
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–

Emo Philips - “My computer beat me at checkers, but I sure beat it at  
kickboxing.”

---

<div class="post-metadata">

**Author:** ![dharmdip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@dharmdip](https://www.ruby-forum.com/u/dharmdip)\
**Post date:** [October 27, 2008, 10:53am UTC](https://www.ruby-forum.com/t/disable-validation-on-edit/151871/5 "2008-10-27T10:53:28Z")

</div>

or you can call:

object.save\_without\_validations

or  
object.save\_with\_validations

although i’d not recommend bypassing your validations.

---

<div class="post-metadata">

**Author:** ![dharmdip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@dharmdip](https://www.ruby-forum.com/u/dharmdip)\
**Post date:** [October 27, 2008, 10:55am UTC](https://www.ruby-forum.com/t/disable-validation-on-edit/151871/6 "2008-10-27T10:55:55Z")

</div>

void wrote:

> or you can call:
> 
> object.save\_without\_validations
> 
> or  
> object.save\_with\_validations
> 
> although i’d not recommend bypassing your validations.

thanks for your reply. I agree that bypassing validation is not  
advisable but in this case i dont want to do as its a manual process…

Thanks a lot
