Saturday, May 25, 2013

InvalidAuthenticityToken while file upload in rails 4

Hi Friends,

Am back again and this time really after a long time. Actually occupied with my current company and it is bootstrapping :) wish me luck.

Any how recent problem that i faced was, uploading file (multipart form request) was giving "ActionController::InvalidAuthenticityToken" error in rails4 while a normal form post was working great, which is kind of strange and it was giving error for synchronous and asynchronous request both.

So whats the way to fix it ? 
Add your own authenticity_token params which is missing in rails form (which is strange again) but add a hidden field something like

<%= hidden_field_tag :authenticity_token, form_authenticity_token -%>

and now everything is back to normal :) i hope for you too.

Thanks
Praveen

1 comment:

  1. good day

    I could facilitate private email to discuss a project
    I want to develop.

    Or email me with me oscaranto@yahoo.com

    Thank you

    ReplyDelete