Hi. I''m setting up an upload form for internal users of a Rails site,
and I''m trying to use the Upload Progress Bar plugin from
http://sean.treadway.info/demo/upload/. I followed the directions as set
out in the Rails Wiki
(http://wiki.rubyonrails.org/rails/pages/Upload+Progress+Bar).
Basically the problem is no progress bar or any upload information shows
up. In WEBrick, I just get "Upload starting..." and then "Upload
finished" after which the page gets redirected as I have it set up in
the view.
I also have my Rails application set up for Apache, so when I try the
same thing, upload a file, I get the same message, "Upload
starting..."
then "Upload finished", only I don''t get a redirect and the
file I
uploaded isn''t there.
This is what my uploads controller looks like:
class UploadsController < ApplicationController
before_filter :authorize
upload_status_for :new
[...]
def new
if request.get?
@upload = Upload.new
else
@upload = Upload.new(@params["upload"])
if @upload.save
flash[:notice] = "File uploaded sueccessfully."
redirect_to :action => "list"
end
end
end
end
And the ''new'' upload view:
<h3>Upload File</h3>
<%= form_tag_with_upload_progress %>
<p><input type="file" id="upload_file"
name="upload[file]"/></p>
<%= render :partial => ''upload_form'' %>
<p><input type="submit"
value="Upload…"/></p>
<%= upload_status_tag %>
</form>
<p><%= link_to ''« Show All Uploads'',
:action => ''list_uploads''
%></p>
Also, if this affects the uploading progress bar process, in my model
I''m specifying that I''ll have the upload saved in the
filesystem. Here
is what the ''upload'' model looks like:
class Upload < ActiveRecord::Base
has_one :movie
belongs_to :movie
def file=(upload_file)
File.open("files/#{upload_file.original_filename}", "w")
{ |f|
f.write(upload_file.read) }
self.filename = upload_file.original_filename
self.content_type = upload_file.content_type
self.size = upload_file.size.to_s
end
def before_destroy
File.delete("files/#{self.filename}")
end
def file_data
IO.read("files/#{self.filename}")
end
end
For the reference, I''m on DreamHost, using Apache 1.3, Ruby 1.8.2, and
Ruby on Rails 1.1 (I have it installed in vendors/rails-1.1). Any help
on this would be much appreciated. Thanks.
-Jon
--
Posted via http://www.ruby-forum.com/.