Use Ruby safe navigation over Rails try

re: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/SafeNavigation
This commit is contained in:
James Mason 2018-05-08 14:17:30 -07:00
parent d8bd269a64
commit 24396d35c2
11 changed files with 26 additions and 27 deletions

View file

@ -312,7 +312,7 @@ class Event < ApplicationRecord
def before_end_of_conference
errors
.add(:created_at, "can't be after the conference end date!") if program.conference && program.conference.end_date &&
.add(:created_at, "can't be after the conference end date!") if program.conference&.end_date &&
(Date.today > program.conference.end_date)
end
@ -324,7 +324,7 @@ class Event < ApplicationRecord
# Allow only confirmed tracks that belong to the same program as the event
#
def valid_track
return unless track && track.program && program
return unless track&.program && program
errors.add(:track, 'is invalid') unless track.confirmed? && track.program == program
end