Join GitHub today
ActiveRecord::Persistence#touch should not use default_scope #1519
Imagine a situation: you have the following
class User < ActiveRecord::Base default_scope :active => true end user = User.unscoped.where(:active => false).first user.touch # This fires sql "UPDATE `users` SET `updated_at` = ? WHERE `users`.`active` = 0" # and so our user instance remains changed (and the database remains unchanged) user.changed? #=> true user.reload # brings old updated_at value back to life
I've provided a test proving that and a fix for the issue.
This is happening in edge (master) and 3.0.7, that I am using currently.
I'd say that this happens since e4943e9 where current