brendon / acts_as_list

An ActiveRecord plugin for managing lists.
http://brendon.github.io/acts_as_list/
MIT License
2.04k stars 355 forks source link

Rails 5.1.0.beta1 deprecation #257

Closed CvX closed 7 years ago

CvX commented 7 years ago

Rails 5.1 deprecates ActiveRecord's changes and other related methods (e.g. attribute_changed?). See: https://github.com/rails/rails/commit/16ae3db5a5c6a08383b974ae6c96faac5b4a3c81 and https://github.com/rails/rails/commit/ef993d36bc952046f312a3695617eaa6d5fe352e

Here's one of the warnings:

DEPRECATION WARNING: The behavior of `attribute_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_change_to_attribute?` instead.

Deprecated use in this gem is here: https://github.com/swanandp/acts_as_list/blob/master/lib/acts_as_list/active_record/acts/list.rb#L396

It's the only one that popped up in my app, but there may be some other deprecated methods in use here.

What's the strategy for handling such deprecations? respond_to?("#{position_column}_before_last_save") … else …?

brendon commented 7 years ago

Hi @CvX, thanks for bringing this to our attention :)

I like to branch based on Rails version in cases like these because that's the determining factor, and the core reason why we're branching. It helps later on when we go to remove support for older Rails versions as we don't then have to figure out when/why the change was implemented.

An example: https://github.com/swanandp/acts_as_list/blob/f9b40e1cbdefe5244b787c66da74148e351af26c/lib/acts_as_list/active_record/acts/sequential_updates_method_definer.rb#L8

Would you like to implement this and modify the Appraisals and travis.yml files? (Remember to run appraisal install to update the individual appraisal files.)