0

I was working on ajax on my rails app and I got a ActionController::InvalidAuthenticityToken error.

and I read this

config.action_view.embed_authenticity_token_in_remote_forms allows you to set the default behavior for authenticity_token in forms with remote: true. By default it's set to false, which means that remote forms will not include authenticity_token, which is helpful when you're fragment-caching the form. Remote forms get the authenticity from the meta tag, so embedding is unnecessary unless you support browsers without JavaScript. In such case you can either pass authenticity_token: true as a form option or set this config setting to true.

from RailsGuides

so I add config.action_view.embed_authenticity_token_in_remote_forms=true to \config\application.rb

and restart rails server ,then an error happened

/Users/haha/railsbridge/railsfun/ruby12weeks/eat/config/application.rb:5:in': undefined local variable or method config' for main:Object (NameError)

Did I put it to wrong place?

this is my github

1 Answers1

0

That line or any config line should be inside Application class, that is after line 12 and before line 16 in your github code

Sajan
  • 1,893
  • 2
  • 19
  • 39
  • 1
    Happens with everyone. If it solves your problem, dont mind to upvote and mark as answer – Sajan Oct 18 '16 at 15:29