Skip to content

Rails 5.1 Deprecation - update dirty methods from enabled_change to saved_change_to_enabled #377

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Subscription < ApplicationRecord
belongs_to :source, polymorphic: true, required: true

before_create :ensure_enabled
after_update :clear_notifications, if: ->{ enabled_change == [true, false] }
after_update :clear_notifications, if: ->{ saved_change_to_enabled == [true, false] }

validates_with SubscriptionUniquenessValidator, on: :create
scope :enabled, ->{ where enabled: true }
Expand Down
2 changes: 1 addition & 1 deletion app/models/subscription_preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SubscriptionPreference < ApplicationRecord

validates :enabled, inclusion: { in: [true, false] }
scope :enabled, ->{ where enabled: true }
after_update :unsubscribe_user, if: ->{ enabled_change == [true, false] }
after_update :unsubscribe_user, if: ->{ saved_change_to_enabled == [true, false] }
validates :email_digest, inclusion: {
in: %w(immediate daily weekly never)
}
Expand Down
Loading