Rails View Encoding Issues
The culprit that was leaking non UTF-8 characters in my template was an innocuous meta tag for Facebook Open Graph
%meta{property: "og:url", content: request.url}
And when the request is non-standard, this causes the encoding issue. Changing it to
%meta{property: "og:url", content: request.url.force_encoding('UTF-8')}
made the trick.
Encoding issues in ActiveModel::Errors
you can alter the behaviour of almost everything in ruby (and rails).
Just create a new initialiser file inside config/initializers with something like this:
#monkeypatch_i18n.rb
(i don't know the exact path of active_model/errors.full_messages)
module ActiveModel
module Errors
def full_messages
#new logic
end
end
end
this overrides the default method.
regards,
juanma.
edit:
A more clean solution could be:
#lib/monkey_patch_i18n.rb
module ActiveModel
module Errors
def full_messages
#new logic
end
end
end
#config/initializers/init_i18n.rb
require "#{Rails.root}/lib/monkey_patch_i18n.rb"
Encoding problems in rails on ruby 1.9.1
I just had this as well so I think its worth having the correct answer.
The 2.8.1 MySql gem is not utf-8 friendly, so it sometimes will return UTF strings and lie to Rails, telling it that they are ASCII when in fact they are UTF-8. This makes things explode.
So: you can either monkey patch or get a compatible MySql gem. See: http://gnuu.org/2009/11/06/ruby19-rails-mysql-utf8/
Rails encoding error. HAML issue I think
tl;dr
Switched to the rdiscount parser and everything works now.
Longer Version:
I'm still not exactly sure what is going on but I know it's in the parser (rpeg-markdown gem).
Another bit of text on the production page had a weird Word apostrophe and that seemed to be the issue. If I wrapped both strings in :markdown filters it all worked, but if either wasn't in a filter I got the encoding error even though everything is utf-8.
I switched to rdiscount and now it works whether or not one (or both) of the blocks are wrapped in a :markdown filter.
Ruby on Rails - UTF8 encoding problems in MySQL from ActiveRecord
The problem was linked to my terminal. I imported the language list through it and I think this was the source of my encoding problem.
I downloaded Sequel Pro to manage my database and all of my data are not corrupted.
Related Topics
How to Execute 2 or More Commands in the Same Ssh Session
Using Delta Indexes for Associations in Thinking Sphinx
How to Refactor Openssl Pkcs5_Keyivgen in Ruby
Rails Activerecord Create or Find
Error When Installing Libv8 3.11.8.3
Read and Write File Atomically
Get Instance Variable Name from Itself in Ruby
Rails: Rake Db:Create:All (Could Not Connect to Server)
Why Does Hash#Select and Hash#Reject Pass a Key to a Unary Block
Pg::Error: Error: Invalid Byte Sequence for Encoding "Utf8": 0Xfc
How Does Count Method Works in Ruby
Does Anyone Have Parsing Rules for the Notepad++ Function List Plugin for Ruby and Rake
Ruby on Rails: Creating a Model Entry with a Belongs_To Association
Garbage Collector in Ruby 2.2 Provokes Unexpected Cow