How and why avoid nil - SumitBisht/checklist_and_guides GitHub Wiki
How and Why To Avoid Nil in Rails
for hashes use
Hash.fetch(key)
active record
-
find works just fine
-
for dynamic finders, use bang methods
Person.find_by_name!(name)
summary
- use your language and librearies intellingently
- invert the object relationshships
- guard against nil with a custom attribute reader
- introduce new domain concepts (like suscriber0)