Before Rails 6, only belongs_to
association accepted touch
option.
When touch
option is set to true, on every commit,
associated object’s timestamp i.e: updated_at
or updated_on
will be set to current time.
After Rails 6, has_one
association also accepts touch
option.
class User
has_one :profile, touch: true
end
Here is the relevant commit adding this change.