This project is archived and is in readonly mode.
[Patch] ActiveRecord::Timestamp#touch still fails when no updated_at/on column is present
-
Neeraj Singh
- Milestone set to 3.x
- State changed from new to open
- Assigned user set to Neeraj Singh
- Importance changed from to Low
-
Neeraj Singh
- Assigned user changed from Neeraj Singh to José Valim
- Tag changed from activerecord, timestamps, touch to activerecord, patch, timestamps, touch
Attached is code with test patch.
-
Repository
- State changed from open to resolved
(from [747e0744dd61561c27ae1b65a74a2b7da7e3f2fe]) @user.touch should not fail if User does not have updated_at/updated_on column.
[#5439 [Patch] ActiveRecord::Timestamp#touch still fails when no updated_at/on colum... state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/747e0744dd61561c27ae1b65a74a2b... -
Repository
(from [aa384de7dd302ccafdfea9963e7b12427c1009e1]) @user.touch should not fail if User does not have updated_at/updated_on column.
[#5439 [Patch] ActiveRecord::Timestamp#touch still fails when no updated_at/on colum... state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/aa384de7dd302ccafdfea9963e7b12... -
Troels Petersen
The patch seems to do the opposite of what was intended:
def touch(name = nil)
attributes = timestamp_attributes_for_update_in_model unless attributes.blank? attributes << name if name ...For a model without an :updated_xx attribute, the attributes variable will be blank, so touch(:other_attribute) does nothing.
I think you need to interchange the lines
unless attributes.blank?
attributes << name if name -
Troels Petersen
- Title changed from ActiveRecord::Timestamp#touch fails when no updated_at/on column is present to [Patch] ActiveRecord::Timestamp#touch still fails when no updated_at/on column is present
Here is a patch to restore the behavior of touch on an arbitrary (date or datetime) attribute.
The point is that since touch has been generalized to update any given attribute, it should do so whether or not the model also has an updated_xx attribute.
-
José Valim
- Milestone cleared.
- State changed from resolved to open
I agree with the patch. I will apply it next week when I give another pass at LH.
-
Repository
- State changed from open to resolved
(from [55b6fa9370dbdac23b0df2bbcb70b2e2d604b410]) restore behavior of touch for models without :updated_xx [#5439 [Patch] ActiveRecord::Timestamp#touch still fails when no updated_at/on colum... state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/55b6fa9370dbdac23b0df2bbcb70b2... -
Repository
(from [bdba74819c6ee5a56d47afedcd7b1ae30e2e0924]) restore behavior of touch for models without :updated_xx [#5439 [Patch] ActiveRecord::Timestamp#touch still fails when no updated_at/on colum... state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/bdba74819c6ee5a56d47afedcd7b1a...
