Created
January 9, 2010 05:03
-
-
Save bhauman/272733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
This is quick fix for getting Rails to recognize Chrome Frame XmlHttpRequests as | |
Ajax Requests so that the following code will work. | |
respond_to do |format| | |
format.js { render :text => "chrome frame won't normally see this" } | |
end | |
Use: | |
Throw this file in to the Rails lib directory. | |
In environment.rb | |
config.middleware.use 'FixForChromeFrameRailsAjax' | |
=end | |
class FixForChromeFrameRailsAjax < Struct.new :app, :options | |
def call(env) | |
if env['HTTP_USER_AGENT'].match(/chromeframe/) && | |
env['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && | |
env['HTTP_ACCEPT'] == '*/*' | |
env['HTTP_ACCEPT'] = 'text/javascript, text/html, application/xml, text/xml, */*' | |
# env['WE_IS_WORKING_CHROME_FRAME'] = 'yes we did' | |
end | |
app.call env | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment