Skip to content

saved_change_to_* return nil in after callbacks in Rails 5.2 #78

Description

@tikh

Looks like it's impossible to detect the previous value of a property in the after callback in Rails 5.2.

I have a simple model:

class Profile < ApplicationRecord
  typed_store :properties do |p|
    p.string :phone
  end

  after_save :debug
  def debug
    puts "saved_change_to_phone #{saved_change_to_phone.inspect}"
  end
end

p = Profile.create(phone: "123")
p.save
p = Profile.last
p.phone = "456"
p.save

# Displays:
# saved_change_to_phone nil

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions