Validation question

If I am validating an object before it is saved and do a find(:all) of
that object class, will the object which is being validated be returned
by
the find method?

something like:

class Resource < ActiveRecord::Base

def validate
resources = Resource.find(:all)
…do stuff
end

Will the object I am validating be in the ‘resources’ array?

Thanks in advance,
Don Mc

“don mc” [email protected] wrote in
message news:[email protected]

If I am validating an object before it is saved and do a find(:all) of
that object class, will the object which is being validated be returned
by
the find method?

yes it does. I use something like this to exclude the record being
validated:

find(:all, :conditions => “id <> #{id}”)

Thanks!

Alan B. wrote:

“don mc” [email protected] wrote in
message news:[email protected]

If I am validating an object before it is saved and do a find(:all) of
that object class, will the object which is being validated be returned
by
the find method?

yes it does. I use something like this to exclude the record being
validated:

find(:all, :conditions => “id <> #{id}”)

It will depend on whether or not the object is a new record. If it’s a
new record, find(:all) won’t pick it up, if it’s been previously
saved, then it will.

-Jonathan.