Answer provided by 'ShadowRanger' in comments. Placing here for visibility
"Looks like your ternary works if you just use plain return (which returns nil when not given an argument). As does (return nil). Guessing it's an issue with the grammar not allowing return and a value in the middle of a ternary conditional expression like that without parentheses. Ruby's grammar is rather ad hoc at times (it's amazing how often spaces matter, relative to most other languages), this doesn't really surprise me"