Skip to content

Commit

Permalink
Rails 5.1 Deprecation - update dirty methods from enabled_change to s…
Browse files Browse the repository at this point in the history
…aved_change_to_enabled (#377)

* update subscription_preference.rb from attr_change to saved_change_to_attr

change made due to rails 5.1 changes to activemodel::dirty

* update subscription.rb change from enabled_change to saved_change_to_enabled
  • Loading branch information
yuenmichelle1 authored Oct 29, 2024
1 parent 8449a61 commit e84061a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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

0 comments on commit e84061a

Please sign in to comment.