Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ernie, play nice with Rails!
# Rails will cause the encoding to slip to ASCII-8BIT for some reason.
# This works fine when all rails libraries aren't loaded onto the ernie process
class Ernie
def self.write_berp(output, ruby)
data = BERT.encode(ruby)
output.write([data.length].pack("N").force_encoding("utf-8"))
output.write(data.force_encoding("utf-8"))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment