Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:24:45+00:00 2026-06-05T13:24:45+00:00

I am submitting a form_for with a file_field in it. When the form is

  • 0

I am submitting a form_for with a file_field in it. When the form is submitted with a post, the controller responds with a .js file which will be executed.

The file_field is optional.

When I upload a file, the js file is opened in a new document (as a simple text file) and the js is not executed. When I don’t upload any file, the response div is updated. I want the update success to be notified in the response div or a failure message independent of the file upload.

May be this is done for some security reasons? Is there some workaround for people who want to be able to do this?

Roughly,

Form partial _action.html.erb:

<div id="response"></div>
<%= form_for ... :remote => true, :url => {..., :format => :js} do |f| %>
    ...
    <%= f.file_field :name %>
<% end %>

Controller::action

 if not request.post?
    render :partial => 'controller/action'
    return
 else
    @response = "save was successful";
    # renders the action.js.erb
 end

action.js.erb:

$("#response").html("<%= @response %>");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:24:45+00:00Added an answer on June 5, 2026 at 1:24 pm

    Try to use remotipart gem https://github.com/JangoSteve/remotipart

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form, basically to upload a file. I am submitting the form
For some reason the following form isn't submitting the file like it should and
I'm submitting a form using an ajax request (POST method), and checking the HTTP
Imagine this simple form for uploading a file: <form action=upload enctype=multipart/form-data> <input type=text name=name/>
I have a html form, with a custom file upload field. And by that
I'm writing the code for a form, and submitting it to a php file
I have a form and I want to upload a file. here is my
I have the following form: <form id=vintro-upload-form action={url}?nexturl={nextUrl} method=post enctype=multipart/form-data > <input name=file type=file/>
I want to make routing for form when submitting the form, $reportRoute = new
I have formatted my form using uniform jquery plugin. Also for submitting the form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.