Flowdock
method

touch

Importance_2
v3.2.8 - Show latest stable - 0 notes - Class: ActiveRecord::Persistence
touch(name = nil) public

Saves the record with the updated_at/on attributes set to the current time. Please note that no validation is performed and no callbacks are executed. If an attribute name is passed, that attribute is updated along with updated_at/on attributes.

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

If used along with belongs_to then touch will invoke touch method on associated object.

class Brake < ActiveRecord::Base
  belongs_to :car, :touch => true
end

class Car < ActiveRecord::Base
  belongs_to :corporation, :touch => true
end

# triggers @brake.car.touch and @brake.car.corporation.touch
@brake.touch
Show source
Register or log in to add new notes.