I'm finding I often have to use a structure to avoid a Rails error of undefined method 'name' for nil:NilClass
.
The structure looks like this:
if country.state
country.state.name
end
It seems like a classic case of repeating oneself with country.state
appearing twice in one simple block. Is there any way to DRY this up?