Using rails 4, I am submitting a form by ajax using remote: true in for_for tag. I have a field to upload image in the form, for image upload paperclip is used.
If I submit the form without uploading image everything works fine. But If I upload a image and then submit the same form I get following error:
ActionController::InvalidAuthenticityToken(ActionController::InvalidAuthenticityToken)
I tried using, "authenticity_token: true" as follows:
<%= form_for @user, :remote => true, authenticity_token: true, :html=>{:class=>"form_validation ", :multipart=>true } do |f| %>
This above piece of code does not give me InvalidAuthenticityToken error but the form is submitted by html and not js(ajax). I want to submit form by ajax.
Is this a CSRF issue or any other issue related to paperclip? Can anyone help me out with this issue.