This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the ruby category.
Last Updated: 2024-10-12
I had the following code:
tracking_info: session[:tracking_info].symbolize_keys
Sometimes the tracking_info
is available in the session
... but sometimes not.
The code blew up in such cases, since symbolize_keys
is not defined on nil
.
Here's the fix:
tracking_info: session[:tracking_info]&.symbolize_keys