Using Ruby on Rails. I’m trying to sort a query by number (saved as string) and letter. However, my letter column can contain “NULL” values. This crashes when there are Null values in the letter column:
@fences = Fence.find(:all,
:conditions => ["coursewalk_id = #{@coursewalk.id}"]).sort_by { |a| [+(a.number.to_i), a.letter] }
How can I fix this?
a.letter.to_sshould do the trick.