Skip to content

Commit a1b61b4

Browse files
committed
Add guard
1 parent 8623caa commit a1b61b4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/controllers/bootcamp_controller.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ def setup_data!
122122
session[:country_code_2] = @country_code_2
123123
end
124124

125-
return unless @bootcamp_data.user_id.nil? && cookies.signed[:_exercism_user_id].present?
126-
127-
@bootcamp_data.update(user_id: cookies.signed[:_exercism_user_id])
125+
# rubocop:disable Style/SafeNavigation
126+
if @bootcamp_data && @bootcamp_data.user_id&.nil? && cookies.signed[:_exercism_user_id].present? # rubocop:disable Style/GuardClause
127+
@bootcamp_data.update(user_id: cookies.signed[:_exercism_user_id])
128+
end
129+
# rubocop:enable Style/SafeNavigation
128130
end
129131

130132
def retrieve_user_bootcamp_data_from_user

0 commit comments

Comments
 (0)