I want to get the render "xxx" 's final HTML code to do something. I can change the file encoding from utf-8 to gb2312 then response it.
My question is, how to achieve this?
I want to get the render "xxx" 's final HTML code to do something. I can change the file encoding from utf-8 to gb2312 then response it.
My question is, how to achieve this?
You probably want an after_filter for something like this. Maybe along the lines of
class ChangeEncodingFilter
def self.filter(controller)
controller.response.body = change_encoding(controller.response.body)
end
end
class YourController < ActionController::Base
after_filter ChangeEncodingFilter
end
where you'll provide the change_encoding method to do the actual work.
Actually, it'll probably require mutation of other things in the response, but the point is that an after_filter can do things with the response just before it's sent.