Google search “file_column ajax upload”:
http://groups.google.com/group/ajaxscaffold/browse_thread/thread/1a85713b55e32324/e36bd44cb02306bb
Should be more than enough to get you started.
Best regards
Peter De Berdt
Google search “file_column ajax upload”:
http://groups.google.com/group/ajaxscaffold/browse_thread/thread/1a85713b55e32324/e36bd44cb02306bb
Should be more than enough to get you started.
Best regards
Peter De Berdt
Both the links were working this morning and practically gave you the entire application. You need to use the responds_to_parent plugin and send your form through an iframe. The rest of the route through the controller is just the same as a normal rjs action, with the exception of wrapping it into a responds_to_parent block.
Best regards
Peter De Berdt
Thanks for the reply,i was able to upload the image with out using ajax.
the problem that i’m facing now is that now i’m getting an RJS error.
can anyone please help.
Your code makes it look as if you’ve either not read the Agile Web Development with Rails book or have the first (and thus quite outdated edition). There’s a lot of stuff there that’s deprecated in Rails 2.
First, make sure you download the responds_to_parent plugin and install it in vendor/plugins:
http://code.google.com/p/responds-to-parent/source
My UPLOAD Controller:
def create
@post=Entry.new(params[:entry])
if @post.save
responds_to_parent do
render :action => “list.rjs”
end
else
responds_to_parent do
render :action => “new.rjs”
end
end
end
My /app/views/upload/new.rhtml:
<% form_tag({:action => ‘create’}, :multipart => true, :target => "frame) %>
<%= render :partial => ‘form’ %>
<div class='button_group'>
<%= submit_tag 'Create' %>
<%= link_to_remote ‘Cancel’, {:url => {:action =>
‘list’}}, {‘class’ => ‘button_group’} %>
</div>
<% end %>
In your rjs files, you can play with the page[“id_of_list”].replace_html commands to do your thing.
Best regards
Peter De Berdt
Please, have a look at the api docs:
Best regards
Peter De Berdt
Don’t have the time to start coding in your place, but I notice you’re not setting the @records instance variable in your create method. Remember that render :action DOESN’T execute the code in the method, it just renders the template.
If you need the @records instance variable in more than one method, you could use a before_filter (see the api.rubyonrails.org api docs).
Another way would be to insert the new record at the bottom of the list using page.insert_html :bottom, … instead of rerendering the complete list.
Did you read the Agile Web Development with Rails book? What you’re asking is all explained nicely in the book.
Best regards
Peter De Berdt