This is an archived forum post. The information may be outdated. Contact us if you have any questions.

CovertHtml with Ruby Api gives undefined method `ord' for nil:NilClass

jimcode wrote on 2013-10-15:
Hi I get the followng error when calling the ConvertHtml method from my code with a HTML string.

If I do a simple test string e.g. "<p>test</p>" it works but with the full complex HTML I need to putput I get the error but can't see where to look to firgure out what I am doing wrong.

undefined method `ord' for nil:NilClass
/home/jim/.rvm/gems/ruby-1.9.2-p290@appstrack/gems/activesupport-3.0.20/lib/active_support/whiny_nil.rb:48:in `method_missing'
/home/jim/.rvm/gems/ruby-1.9.2-p290@appstrack/gems/activesupport-3.0.20/lib/active_support/core_ext/string/output_safety.rb:163:in `gsub'
/home/jim/.rvm/gems/ruby-1.9.2-p290@appstrack/gems/activesupport-3.0.20/lib/active_support/core_ext/string/output_safety.rb:163:in `gsub'
/home/jim/.rvm/gems/ruby-1.9.2-p290@appstrack/gems/pdfcrowd-2.6.0/lib/pdfcrowd.rb:326:in `call_api_urlencoded'
/home/jim/.rvm/gems/ruby-1.9.2-p290@appstrack/gems/pdfcrowd-2.6.0/lib/pdfcrowd.rb:99:in `convertHtml'
/home/jim/appstrack/appstrack/lib/tasks/documents.rake:39:in `block (3 levels) in <top (required)>'
/home/jim/.rvm/gems/ruby-1.9.2-p290@appstrack/gems/activerecord-3.0.20/lib/active_record/relation.rb:13:in `each'
/home/jim/.rvm/gems/ruby-1.9.2-p290@appstrack/gems/activerecord-3.0.20/lib/active_record/relation.rb:13:in `each'
/home/jim/appstrack/appstrack/lib/tasks/documents.rake:22:in `block (2 levels) in <top (required)>'
jimcode wrote on 2013-10-15:
This seems to be to do with UTF-8 encoding. When I pass a normal string it works (and has ASCII encoding) but passing the output from a rails view which is UTF-8 it gives the above error.
support wrote on 2013-10-15:
Hello,

After some googling I found this: https://github.com/jharig23/twilio-test/blob/master/README.md

For now, a workaround should be to convert ActiveSupport::SafeBuffer to String before passing it to convertHTML().