Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tikh opened this issue Oct 2, 2019 · 0 comments
Open

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

tikh opened this issue Oct 2, 2019 · 0 comments

Comments

@tikh
Copy link

tikh commented Oct 2, 2019

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant