See this Pastie, which makes use of File.socket?, Enumerable‘s amazing detect and an ERb variable.
On the #rubyonrails.se IRC channel, simmel made the recipe better by adding the check for File.socket?, instead of File.exists?. (File.socket? will follow symbolic links, as you can see in the pasted code.)
A recipe variation, you might call it.