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

"changed?" method will be changed in rails #1085

Closed
joker-777 opened this issue Feb 22, 2018 · 2 comments
Closed

"changed?" method will be changed in rails #1085

joker-777 opened this issue Feb 22, 2018 · 2 comments

Comments

@joker-777
Copy link

Hello,

we get a depreciation warning which indicates that you use the method changed? which will be changed in future.

DEPRECATION WARNING: The behavior of `changed?` inside of after callbacks will be changing in the next version of Rails. The new return value will reflect the behavior of calling the method after `save` returned (e.g. the opposite of what it returns now). To maintain the current behavior, use `saved_changes?` instead.

We get this error because we update the model in an after_create callback which also uses thinking sphinx.

More information which methods will change can be found here rails/rails#25337 (comment)

@pat
Copy link
Owner

pat commented Feb 24, 2018

I believe this happens because TS fires its own change to the model (I'm presuming you're using deltas), which means there's another full cycle of callbacks in the inner save - and in there, it's calling changed? within the before_save. Rails' deprecation warning doesn't distinguish about the inner callback within the outer callback.

This has also been discussed in #1059.

@joker-777
Copy link
Author

OK, it makes sense. Thanks a lot for your response.

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

2 participants