Skip to content

Commit

Permalink
Rails 5.1 - Update board.rb replacing deprecated methods of attr_chan…
Browse files Browse the repository at this point in the history
  • Loading branch information
yuenmichelle1 authored Sep 27, 2024
1 parent aa6dd9e commit 953402e
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 953402e

Please sign in to comment.