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 -- Posted via http://www.ruby-forum.com/.
"don mc" <don.mcclean@gmail.com> wrote in message news:43188408f875847139da97816c80254c@ruby-forum.com...> 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 Bullock wrote:> "don mc" <don.mcclean@gmail.com> wrote in > message news:43188408f875847139da97816c80254c@ruby-forum.com... >> 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}")-- Posted via http://www.ruby-forum.com/.
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. On 7/14/06, Alan Bullock <liststuff@gmail.com> wrote:> "don mc" <don.mcclean@gmail.com> wrote in > message news:43188408f875847139da97816c80254c@ruby-forum.com... > > 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}") > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >