Open ghost opened 10 years ago
Thanks! I was uploading files successfully, but my JS was nonetheless getting an ajax:error response. Adding :data => { :type => 'text' }
to the form fixed it.
If it helps anyone, this is my controller code:
def create
@contact_document = ContactDocument.new(contact_document_params)
if @contact_document.save
render json: @contact_document
else
render json: { errors: @contact_document.errors.full_messages }, status: 422
end
end
A successful save was returning an ajax:error condition before I added :data => { :type => 'text' }
to the form. After that, it started returning the ajax:success condition I was expecting.
This same thing was happening for me. I tried type: :text
and it was still a little off. Using type: :json
worked for me!
type: 'text'
works for me (with an HTML response).
This should probably be on the Readme.md
I also had this problem and then found this issue. It would be good if this was on the README.
Add the :data => { :type => 'text' } to the form tag
:html => { :multipart => true, :data => { :type => 'text' } } }
works for you?