Redrick
Redrick

Reputation: 466

rails 4 simple_form_tag remote: true loaded through ajax

I got myself a problem:

I am loading a simple modal widow in which there is a plus sign, which got onclick ajax call which returns form with remote:true..

This I want to submit without reload (obviously remote:true should take care of that) but every time I hit submit the whole page reloads and it gives me ActionController::InvalidAuthenticityToken error, which means that it is trying to "normal" submit it not through ajax...

Thats about it in nutshell, please let me know which code to paste here or if you encountered something like this (seems like jquery_ujs is not binding properly ...)

Please do not mark me as duplicate, I found many people dealing with similar problems, but no solution, believe me I tried many things...

EDIT: seems related to:

https://github.com/rails/jquery-ujs/issues/265

Upvotes: 1

Views: 456

Answers (1)

Abhiram
Abhiram

Reputation: 1489

In Rails 4, aunthenticy token is not added by default, so add this line in you application.rb

config.action_view.embed_authenticity_token_in_remote_forms = true

By this the authenticity token will be taken from the meta tag.

Upvotes: 1

Related Questions