Corey
Corey

Reputation: 2563

Rails 6 remote: true and multipart: true file uploads not working

Can you upload files in a Rails 6 form with remote: true?

My form has remote: true and multipart:true, and works without issue when I do not upload any files.

Once I try to upload a file, I get a 406 error, and in my logs I'm seeing:

ActionController::UnknownFormat (AppProxy::RegistriesController£update is missing a template for this request format and variant.

request.formats: ["text/html"]

It seems only when I try to upload an image, I'm getting this error, otherwise my update.js.erb is running fine when other fields are saved and no files are uploaded.

Edit: It appears that the uploads are in fact saving despite the error, but I'm still only seeing this error when the form has uploads.

Upvotes: 1

Views: 1074

Answers (2)

sonal save
sonal save

Reputation: 118

add gem 'remotipart' in Gemfile

//= require jquery.remotipart add this line in app/assets/javascripts/application.js (right after //= require jquery_ujs):

Upvotes: 0

Corey
Corey

Reputation: 2563

I assumed remotipart wasn't going to work because it explicitly says it's for Rails 3 and 4, but alas, it did work for me.

Upvotes: 0

Related Questions