diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-06-09 17:30:00 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-06-18 19:08:41 +0900 |
commit | cad0b7d91dbc5abf4b0d7fdbcf2d0620557a3b0f (patch) | |
tree | 9931a8eb4a452c9de635661cad42353750452c43 /activerecord/test/models | |
parent | a865f621ee934e8741001bbed1b487698e44d914 (diff) | |
download | rails-cad0b7d91dbc5abf4b0d7fdbcf2d0620557a3b0f.tar.gz rails-cad0b7d91dbc5abf4b0d7fdbcf2d0620557a3b0f.tar.bz2 rails-cad0b7d91dbc5abf4b0d7fdbcf2d0620557a3b0f.zip |
Fix `touch` option to behave consistently with `Persistence#touch` method
`touch` option was added to `increment!` (#27660) and `update_counters`
(#26995). But that option behaves inconsistently with
`Persistence#touch` method.
If `touch` option is passed attribute names, it won't update
update_at/on attributes unlike `Persistence#touch` method.
Due to changed from `Persistence#touch` to `increment!` with `touch`
option, #31405 has a regression that `counter_cache` with `touch` option
which is passed attribute names won't update update_at/on attributes.
I think that the inconsistency is not intended. To get back consistency,
ensure that `touch` option updates update_at/on attributes.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/car.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/wheel.rb | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/test/models/car.rb b/activerecord/test/models/car.rb index 3d6a7a96c2..8614926626 100644 --- a/activerecord/test/models/car.rb +++ b/activerecord/test/models/car.rb @@ -20,6 +20,8 @@ class Car < ActiveRecord::Base scope :incl_engines, -> { includes(:engines) } scope :order_using_new_style, -> { order("name asc") } + + attribute :wheels_owned_at, :datetime, default: -> { Time.now } end class CoolCar < Car diff --git a/activerecord/test/models/wheel.rb b/activerecord/test/models/wheel.rb index 8db57d181e..22fc74995f 100644 --- a/activerecord/test/models/wheel.rb +++ b/activerecord/test/models/wheel.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class Wheel < ActiveRecord::Base - belongs_to :wheelable, polymorphic: true, counter_cache: true, touch: true + belongs_to :wheelable, polymorphic: true, counter_cache: true, touch: :wheels_owned_at end |