Hi, It seems that the validate method in ActiveRecord is not call when doing an myActiveRecordObject.update, right ? So, I call the save method instead, and the validation happens... some has an explanation ? thanks arnaud
Arnaud, ActiveRecord''s update method calls update_attributes internally. Validation will occur with update_attributes. Check the rdocs for more info. -- Zack Chandler http://depixelate.com On 8/10/06, Arnaud Garcia <arnaud.garcia@sim.hcuge.ch> wrote:> Hi, > > It seems that the validate method in ActiveRecord is not call when doing > an myActiveRecordObject.update, right ? > > So, I call the save method instead, and the validation happens... > > some has an explanation ? > > thanks > arnaud > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Arnaud Garcia wrote:> It seems that the validate method in ActiveRecord is not call when doing > an myActiveRecordObject.update, right ?Maybe this helps: update(id, attributes) Finds the record from the passed id, instantly saves it with the passed attributes (if the validation permits it), and returns it. If the save fails under validations, the unsaved object is still returned. The arguments may also be given as arrays in which case the update method is called for each pair of id and attributes and an array of objects is returned. Example of updating one record: Person.update(15, {:user_name => ''Samuel'', :group => ''expert''}) Dirk