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

@ -13,10 +13,10 @@ class RegistrationPeriod < ApplicationRecord
def before_end_of_conference
errors
.add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date)
.add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference&.end_date && start_date && (start_date > conference.end_date)
errors
.add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date)
.add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference&.end_date && end_date && (end_date > conference.end_date)
end
def start_date_before_end_date