Hello, I am saving/updating same object on different pages with some validations. On first page, I save my object and on 2nd, 3rd, 4th pages i update the same object. So at first page i am using validates_inclusion_of :in => [] etc, and in second page(updating), i am using validates_presence_of :abc, :on => [:update]. But while i update on 3rd page also, i need some validations but i can not find out which function should i use. If i use validates_presence_of .. then this validations is reflecting on save page, And if i use validates_presence_of :on => [:update] then that is reflecting on update page. so i am in a bit of dilemma that what should i use. Thanks in advance. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Nov 15, 5:12 am, Hemant Bhargava <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > > I am saving/updating same object on different pages with some > validations. On first page, I save my object and on 2nd, 3rd, 4th pages > i update the same object. So at first page i am using > validates_inclusion_of :in => [] etc, and in second page(updating), i am > using validates_presence_of :abc, :on => [:update]. But while i update > on 3rd page also, i need some validations but i can not find out which > function should i use. > If i use validates_presence_of .. then this validations is reflecting on > save page, And if i use validates_presence_of :on => [:update] then that > is reflecting on update page. so i am in a bit of dilemma that what > should i use.The :if options to the various validations allows you to specify your own logic as to which validations should run given the state of the object. Fred> > Thanks in advance. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Hello Fred, Thanks for a quickie. But did''nt quite get it. Is it something like this? validates_presence_of :abc_column, :on => :update, :if => some_method .. and then this method should be defined somewhere. def some_method if particular_param_is_present return true end return false end Fred, am i doing correct here. I have tried it this way, but this validation is still coming in all pages. I mean other pages also where i am updating. Frederick Cheung wrote in post #961482:> The :if options to the various validations allows you to specify your > own logic as to which validations should run given the state of the > object. > > Fred-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.