Skip to content

Instantly share code, notes, and snippets.

@rhunter
Created April 6, 2011 00:11
Show Gist options
  • Save rhunter/904866 to your computer and use it in GitHub Desktop.
Save rhunter/904866 to your computer and use it in GitHub Desktop.
diff --git a/app/controllers/api/goals/base_controller.rb b/app/controllers/api/goals/base_controller.rb
index 9b7f43e..8c4dae5 100644
--- a/app/controllers/api/goals/base_controller.rb
+++ b/app/controllers/api/goals/base_controller.rb
@@ -13,9 +13,11 @@ class Api::Goals::BaseController < BaseApplicationController
# This is unnecessary in Rails 3, thanks to responds_to
def respond_to_json(*args)
# Rails 2 doesn't seem to provide a convenient way to follow Accept order, so "first" will do
- return unless self.request.accepts.any? {|mime_type| mime_type.to_sym == :json}
+ supported_mime_type = self.request.accepts.detect {|mime_type| mime_type.to_sym == :json}
+ return unless supported_mime_type
- self.request.format = :json
+ self.request.format = supported_mime_type
+ self.response.content_type = supported_mime_type
end
ssl_exceptions # no exceptions by default, everything is SSL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment