Hi,
Recently I was working on a simple rails application (Rails 4) and I create a simple remote form for a model.
Things were fine but when I submit the form using javascript, it gave me an authenticity token error:
ActionController::InvalidAuthenticityToken
I read up(googled) a bit and figured that one has to set crsf_meta_tags in layout and not doing this creates the issue. I thought I had missed it somehow but to my dismay it was there but still I had the issue !
The problem was that in normal forms(remote => false) , rails automatically sets the authenticity token but not so in remote forms. Now there can be many work arounds like suggested here.
But the most rails way ! of doing it is adding the following in application.rb:
config.action_view.embed_authenticity_token_in_remote_forms = true
Once you restart your server, voila ! it will work.
A good reading can be found here
Hope it helps !