Fix 'undefined method `gsub' for nil:NilClass' when undefined method is called.

http://stackoverflow.com/questions/18037596/error-undefined-method-gsub-for-nilnilclass/18038912