Forum: Ruby on Rails form_tag_with_upload_progress

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Trung T. (Guest)
on 2006-02-04 20:42
hi all!

i have a PictureController with an upload action:

class PictureController < ApplicationController
.
.
.
upload_status_for :upload
.
.
.
def upload
  if params[:picture]
    @message = "File uploaded: " + params[:picture][:file].size.to_s
    picture = Picture.save(params[:picture])
    session.update
    finish_upload_status "'#{@message}'"
  end
end
.
.
.
end

and the model:

class Picture < ActiveRecord::Base
.
.
def self.save(picture)
  #save the picture here
end
.
.
end

and the view:

<%= form_tag_with_upload_progress({:action => 'upload'}, {:begin => "new
Effect.Appear('status1')", :finish => "new
Ajax.Request('/picture/upload', {asynchronous:true});" }) %>
.
.
	<%= file_field 'picture', 'file' %>
	<%= submit_tag 'Upload' %>
	<div id="status1" style="display:none;width:80%;">
		<%= upload_status_tag %>
	</div>
<%= end_form_tag %>

after finish upload it makes an ajax request to the same action,
this works fine but if i take a look at the console where i have started
the webbrick server, i can see that it calls permanently the
/picture/upload_status?upload_id=.. with different frequencies
this can't be correct??
what am i doing wrong??

thanks for help!
This topic is locked and can not be replied to.