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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 27, 8:56 am, Dharmdip Rathod <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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> > Thanks > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 Rathod <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > -- > Posted via http://www.ruby-forum.com/. > > > >-- Emo Philips - "My computer beat me at checkers, but I sure beat it at kickboxing." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
or you can call: object.save_without_validations or object.save_with_validations although i''d not recommend bypassing your validations. On 27 Okt., 10:47, "zuo peng" <cn.peng....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 Rathod > > > > <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > 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 > > -- > > Posted viahttp://www.ruby-forum.com/. > > -- > > Emo Philips - "My computer beat me at checkers, but I sure beat it at > kickboxing."--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---