Trouble with AJAX-like uploads

So I’ve been following various tutorials to implement an ajax-like file
upload using responds_to_parent and iframe targets, but can’t quite
close the deal. My file uploads successfully, but the rjs doesn’t work
(my ‘events’ partial, which refreshes fine with this controller code
when called with form_remote_tag, doesn’t refresh).

Can anyone who’s done this before see what’s missing?

Thanks,

Peter

View:

<% form_tag({:action=>‘upload’}, :multipart => true, :target => “frame”)
do %>
<%= file_field_tag “uploaded_file” %>
<%= submit_tag ‘Upload’ %>
<% end %>

Controller:

def upload
event = Event.new
event.date = Date.today
if event.save
File.open("#{RAILS_ROOT}/uploaded.rtf", “wb”) do |f|
f.write(params[‘uploaded_file’].read)
end
responds_to_parent do
render :update do |page|
page.replace_html “event_list”, :partial => “events”
end
end
end
end

I should also mention that I get the following RJS error upon
submission:

TypeError: Value undefined (result of expression Element.update) is not
object.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs