Is it possible to get rails to decode query parameters to utf8.
If i have something like /foo?param=£
And I try to access the parameter in my controller the parameter is encoded as ASCII-8BIT. This causes lots of things to break because a lot of our other strings are encoded UTF-8 and ruby doesn’t like mixing encodings.
params[:param].encoding == Encoding.find("ASCII-8BIT")
This solution is taken from the brilliant article at http://jasoncodes.com/posts/ruby19-rails2-encodings
Thanks a mill to Jason Weathered for this!
If you are on the Rails 2.3.x series, you need to create a file called config/initializers/utf8_params.rb with following content to fix the problem
Be sure to check out the other tips in the article, especially around magic comments in views. Thanks again Jason.