1

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?

1
  • using javascript and the DOM? not sure I understand what you want though. Commented Mar 10, 2011 at 2:34

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.