method

touch

rails latest stable - Class: ActiveRecord::Timestamp

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

touch(attribute = nil)
public

Saves the record with the updated_at/on attributes set to the current time. If the save fails because of validation errors, an ActiveRecord::RecordInvalid exception is raised. If an attribute name is passed, that attribute is used for the touch instead of the updated_at/on attributes.

Examples:

  product.touch               # updates updated_at
  product.touch(:designed_at) # updates the designed_at attribute

1Note

Validations

sfusion ยท Mar 17, 2010

out of the box touch will run with validations