Skip to content

Instantly share code, notes, and snippets.

@bhauman
Created January 9, 2010 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhauman/272733 to your computer and use it in GitHub Desktop.
Save bhauman/272733 to your computer and use it in GitHub Desktop.
=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