Skip to content

Instantly share code, notes, and snippets.

@mikz
Created May 27, 2012 12:27
Show Gist options
  • Save mikz/2813751 to your computer and use it in GitHub Desktop.
Save mikz/2813751 to your computer and use it in GitHub Desktop.
Make Rails 2.3.x play nice with Ruby 1.9.x. Forces encoding to UTF8 for every string in parameters.
module UTF8
module Params
private
def normalize_parameters_with_encoding(value)
normalize_parameters_without_encoding(value).tap do |value|
value.force_encoding(Encoding.default_external) if value.respond_to?(:force_encoding)
end
end
end
end
ActionController::Request.class_eval do
include UTF8::Params
alias_method_chain :normalize_parameters, :encoding
end
@loveybot
Copy link

Yay Ruby!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment