Ruby: "keyerror: key not found" error

Example:

hash = {a: 1, b: 2}
hash[:c]
Occurs when you try to access a hash key that doesn't exist.

Solution:

hash.fetch(:c, "Default value")

Beginner's Guide to Ruby