Active record validation with mongrel_upload_progress

August 19th, 2007 by Prateek Dayal | Print Active record validation with mongrel_upload_progress

The active record validation is finally working with mongrel_upload_progress … yayee. To read more about what the issue was, follow this post

I will try to explain my setup and then the solution to the problem

I am trying to watch /song/upload with mongrel_upload_progress plugin. Inside /song/upload, I save the song if the validation passes (such as file size, title present etc) otherwise I want to display some errors on the upload page. The problem is that since the page is not reloaded, the <%=error_messages_for :song %> does not work.

I employed a simple solution to fix this. I put <%= error_messages_for :song %> in a div like this

<div id="err_msg" ><%="error_messages_for"></div>

and in the song_controller/upload method, if the validation fails, I do the following


responds_to_parent do # execute the redirect in the main window
render :update do |page|
page[:err_msg].replace_html(error_messages_for("song"))
end
end

This displays the error messages for the upload even without the page being refreshed.

Popularity: 10% [?]

 
blog comments powered by Disqus