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

Rails 5.1 Deprecation Warning- Update board.rb replacing deprecated methods attr_changed? and attr_was #372

Merged
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
6 changes: 3 additions & 3 deletions app/models/board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Board < ApplicationRecord
validates :description, presence: true
validates :section, presence: true

after_update :cascade_searchable_later, if: :permissions_changed?
after_update :cascade_searchable_later, if: :saved_change_to_permissions?

def searchable?
permissions['read'] == 'all'
Expand All @@ -44,9 +44,9 @@ def count_users_and_comments!
end

def cascade_searchable_later
action = if permissions_was['read'] == 'all' && permissions['read'] != 'all'
action = if permissions_before_last_save['read'] == 'all' && permissions['read'] != 'all'
:destroy_searchable # was public, but isn't now
elsif permissions_was['read'] != 'all' && permissions['read'] == 'all'
elsif permissions_before_last_save['read'] != 'all' && permissions['read'] == 'all'
:update_searchable # wasn't public, but is now
end

Expand Down
Loading