I know I'm a bit late to the party, but one more solution is (in case you have single page app) to remove the csrf snippet (in the layout) altoghether, and instead use:
<script>
var csrf_token = "<%= form_authenticity_token %>";
</script>
And then configure $httpProvider:
app.config ["$httpProvider", (provider) ->
provider.defaults.headers.common['X-CSRF-Token'] = csrf_token
]
On Wednesday, July 4, 2012 1:51:36 PM UTC+2, Jakub Arnold wrote:
It works perfectly, thanks. Just in case anyone else is wondering, you need to wrap the code in a config block to get the provider, such as
var module = angular.module('mypp', []);
module.config(["$httpProvider", function(provider) {
provider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
}]);