Skip to content

Instantly share code, notes, and snippets.

@sakatam
Created June 19, 2014 07:44
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 sakatam/f40d93f911930ade0d68 to your computer and use it in GitHub Desktop.
Save sakatam/f40d93f911930ade0d68 to your computer and use it in GitHub Desktop.
AngularJS x Rails - $httpモジュールからの XHR が text/html と認識されちゃう問題 ref: http://qiita.com/sakatam/items/feff580add9b76e6f538
$httpProvider.defaults.headers.common["Accept"] = 'application/json';
$httpProvider.defaults.headers.common["Accept"] = 'application/json';
BROWSER_LIKE_ACCEPTS = /,\s*\*\/\*|\*\/\*\s*,/
def valid_accept_header
(xhr? && (accept.present? || content_mime_type)) ||
(accept.present? && accept !~ BROWSER_LIKE_ACCEPTS)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment