mongoid/mongoid — Issue #1798: Support for the :touch option in relations
Author: Nerian
Created: 2012-03-07 19:11:24+00:00
State: open

Feature: Support :touch option in relations.

```ruby
class Person
include Mongoid::Document
include Mongoid::Timestamps

field :name

has_one :job, :touch => true
end

class Job
include Mongoid::Document
include Mongoid::Timestamps

belongs_to :person, :touch => true
end
```

Given I have a person with a job.

```ruby
Person.work = Jon.new
```

Saved

```ruby
Person.save
Person.updated_at
=> 2012-03-07 19:03:15 +0100
```

When I change person and save it, jon's update_at field is updated too:

```ruby
person.name = 'Cervantes'
person.save
person.updated_at
=> 2012-03-07 19:05:15 +0100
job.updated_at
=> 2012-03-07 19:05:15 +0100
```