I have a .coffeescript.erb file in which I would like to get CSRF meta-tag information in Rails 3.1. The file is called bookmarklet.coffee.erb and it is in my assets/javascript folder. This is the code I am using:
csrfMeta = <%= csrf_meta_tags %>
When I access assets/bookmarklet.js, I see this in my server log
Error compiling asset bookmarklet.js:
NameError: undefined local variable or method `csrf_meta_tags' for #<#<Class:0x007f83d2efc3a8>:0x007f83d4043080>
How can I get the CSRF meta tags into my javascript file?
I managed to get the CSRF tags to show up by moving the file into my views/parser folder, and renaming it as bookmarklet.js.coffee. Instead of using csrf_meta_tags, I used the helper form_tag which automatically includes the CSRF tags.