ajax - rails in_place_edit: how do I pass an authenticity token? - Stack Overflow

admin2022-05-08  29

I am trying to get in place editing working but I am running into this error:

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken)

I understand that rails now wants to protect against forgery and that I need to pass a form authenticity token but I am not clear on how to do this with the in_place_edit plugin.

Answers:

I am trying to get in place editing working but I am running into this error:

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken)

I understand that rails now wants to protect against forgery and that I need to pass a form authenticity token but I am not clear on how to do this with the in_place_edit plugin.

Answers:

This isn't a complete tested answer, but I took a look at the plugin code, and it looks like you could use the :with option to tack the authenticity token onto the end of the request parameters. Something along the lines of:

in_place_editor("my_element", :with => "form.serialize() + '&authenticity_token=#{form_authenticity_token}';")

(I have not tested the above code).

Answers:

I found a solution. I put the instructions here. Take a look at the part on patching in_place_edit.

转载请注明原文地址:https://en.jsonjs.com/read-91949.html

New Post(0)