<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Prateek Dayal &#187; ajax</title>
	<atom:link href="http://www.prateekdayal.net/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.prateekdayal.net</link>
	<description>Ruby on Rails + Web 2.0 + Life :)</description>
	<lastBuildDate>Fri, 20 May 2011 16:13:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Active record validation with mongrel_upload_progress</title>
		<link>http://www.prateekdayal.net/2007/08/19/active-record-validation-with-mongrel_upload_progress/</link>
		<comments>http://www.prateekdayal.net/2007/08/19/active-record-validation-with-mongrel_upload_progress/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 15:38:21 +0000</pubDate>
		<dc:creator>Prateek Dayal</dc:creator>
				<category><![CDATA[activerecord]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[upload_progress]]></category>

		<guid isPermaLink="false">http://prateekdayal.net/blog/?p=10</guid>
		<description><![CDATA[The active record validation is finally working with mongrel_upload_progress &#8230; 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 [...]]]></description>
			<content:encoded><![CDATA[<p>The active record validation is finally working with mongrel_upload_progress &#8230; yayee. To read more about what the issue was, follow <a href="http://prateekdayal.net/blog/?p=5" >this post</a></p>
<p>I will try to explain my setup and then the solution to the problem</p>
<p>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  <code> &lt;%=error_messages_for :song %&gt; </code>  does not work.</p>
<p>I employed a simple solution to fix this. I put <code> &lt;%= error_messages_for :song %&gt;  </code> in a div like this</p>
<p><code>  &lt;div id="err_msg" &gt;&lt;%="error_messages_for"&gt;&lt;/div&gt;</code></p>
<p>and in the song_controller/upload method, if the validation fails, I do the following</p>
<p><code><br />
responds_to_parent do # execute the redirect in the main window<br />
  render :update do |page|<br />
    page[:err_msg].replace_html(error_messages_for("song"))<br />
  end<br />
end<br />
</code></p>
<p>This displays the error messages for the upload even without the page being refreshed.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.prateekdayal.net%2F2007%2F08%2F19%2Factive-record-validation-with-mongrel_upload_progress%2F';
  addthis_title  = 'Active+record+validation+with+mongrel_upload_progress';
  addthis_pub    = 'prateek';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.prateekdayal.net/2007/08/19/active-record-validation-with-mongrel_upload_progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

