For some reason I cannot use render in a one line conditional.
Example, this works:
@key = Key.find_by_patient_id(5).nil? ? @key : @key
But this does not:
@key = Key.find_by_patient_id(5).nil? ? render :index : render :index
Error message:
syntax error, unexpected tSYMBEG,
expecting keyword_do or ‘{‘ or ‘(‘
…y_patient_id(5).nil? ? render
:index : render :index
It’s because the colon is ambiguous whether it represents a symbol or the separator. Grouping each condition should fix the syntax error: