Ruby On Rails OCD

Michael Forrest
Fri 05 Sep 2008
I had to put this in one of my application initialisers. Yes, I am clearly way too perfectionist...
            class Array
              alias :to_wrong_sentence :to_sentence 
              def to_sentence
                  to_wrong_sentence(:skip_last_comma=>true)
              end
            end
            

Default behaviour without fix:
['egg','beans','chips'].to_sentence # -> egg, beans, and chips

Default behaviour with fix:
['egg','beans','chips'].to_sentence # -> egg, beans and chips

PHEW.

0 comments on "Ruby On Rails OCD"

Make a comment