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 5843999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:13:59+00:00 2026-05-22T12:13:59+00:00

So, I am using a :remote => true form with the paperclip gem to

  • 0

So, I am using a :remote => true form with the paperclip gem to upload a photo. When I submit the form I just want to refresh the content of a div (which will now contain the uploaded photo).

Rails, however, insists on redirecting me to the path of the action used to process the photo submission. Additionally, there is the issue of actually refreshing the div.

I would like to do it with javascript, but there is no afterSubmit handler or anything. I can’t figure out how to respond to the form submit with javascript either. I tried to do

def add_photo
  SomeModel.method_that_processes_and_saves(params)
  respond_to do |format|
    format.js 
  end
end

and placing the script in add_photo.js.erb. However, the script is never sent (the browser is asking for html?) How can I get around this?? Its been frustrating me for a whole day now.

  • 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-05-22T12:14:00+00:00Added an answer on May 22, 2026 at 12:14 pm
    def add_photo
      SomeModel.method_that_processes_and_saves(params)
      respond_to do |format|
        format.js{ render :update do |page|
          page << "$('#mydiv').html('bah-blah') "
      end
    end
    

    Or create add_photo.js.erb and write there any javascript you want.

    It will work if you’re submitting your form via AJAX (js request), that mean that you should add :remote => true option

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

Sidebar

Related Questions

I have a remote form with hand-made buttons using tags. I'm using data-remote=true in
i am trying to update a div using form_for :remote => true, but its
I have a Rails 3.0 app which is using a normal :remote => true
Can Maven copy local file to a remote server using SSH? I want to
Is it possible to get data from remote server using JUST TSQL? I mean
Here how my rails form looks like: - form_tag rel_references, :remote => true, :id=>references_form,
I need advice for a form with :remote => true. I need remote =>
This form works 100% when using the normal non-remote request. However when I set
I am using Rails 3.0.3 with jQuery ujs. I want to send a form
It's not the only remote form I'm using, but I can't see the problem

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.