This code fetches the content in plain text or html, and displays it on the page.
A HTML form with the fields post_id content POSTS to edit_post in my controller. I'm using Sequel ORM and Ramaze.
def edit_post
Encoding.default_external = 'utf-8'
data = request.subset(:content, :post_id)
shake = Post[data['post_id']]
data.delete('post_id');
shake.update(data); shake.save
end
The only symbols inside data['content'] is % , . ' and "
The desired behaviour is that the POST data submitted through the form updates the row in the database. This is the string I was trying to post. It contains this line that includes 2 percent signs (%):
A scientific study showed that men want more sex partners than women, in every country. Only 2% of lesbians have had over 1000 sexual partners, but 28% of gays have had over 1000.
The table row requires a "content" and "post_id" column.
It looks like there's a problem with the % symbol being used to update the database. I believe the default encoding to be CP850. How do I change my Ramaze app to stop using CP850 and use UTF-8 instead?
I have the following code in model/init.rb
Sequel::Model.plugin :force_encoding, 'UTF-8'
Encoding.default_external = 'utf-8'