Urgent + Validations

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.

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

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: