<?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; activerecord</title>
	<atom:link href="http://www.prateekdayal.net/category/activerecord/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>Funding your startup by consulting on the side</title>
		<link>http://www.prateekdayal.net/2009/05/26/funding-your-startu-by-consulting-on-the-side/</link>
		<comments>http://www.prateekdayal.net/2009/05/26/funding-your-startu-by-consulting-on-the-side/#comments</comments>
		<pubDate>Tue, 26 May 2009 18:52:41 +0000</pubDate>
		<dc:creator>Prateek Dayal</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[activerecord]]></category>

		<guid isPermaLink="false">http://www.prateekdayal.net/?p=170</guid>
		<description><![CDATA[I was part of the panel discssion at the  xtremestartups event on Sunday and one of the topics we discussed was funding a startup by consulting on the side. I strongly believe in two things &#8211; bootstrapping and working full-time on one&#8217;s startup &#8211; but there are real costs involved in starting up that one [...]]]></description>
			<content:encoded><![CDATA[<p>I was part of the panel discssion at the  <a href="http://entrypreneur.blogspot.com/2009/05/xtreme-starups-iim-bangalore.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/entrypreneur.blogspot.com');">xtremestartups</a> event on Sunday and one of the topics we discussed was funding a startup by consulting on the side. I strongly believe in two things &#8211; bootstrapping and working full-time on one&#8217;s startup &#8211; but there are real <a href="http://www.prateekdayal.net/2009/05/20/costs-involved-in-starting-up/" >costs involved in starting up</a> that one needs to take care of. In case one doesn&#8217;t  have enough money saved up, consulting is the only feasible option (other than getting funded). It&#8217;s best to avoid even consulting (by running a lean and mean start-up) as it takes one&#8217;s focus off the start-up. But most times it is inevitable and I recommend the following tips to make the best out of your consulting stint.</p>
<p><strong>Pick the right projects</strong></p>
<p>Of all the things that I have learnt about consulting, this is the most important one. Here are a few guidelines that can help you pick the right projects.</p>
<ul>
<li>Charge by the hour and never opt for fixed budget projects however-much enticing they are. All software projects tend to get delayed. The delays don&#8217;t mean much if you are in the consulting business, but if you are trying to raise cash for your startup, every extra day lost  reduces your product development runway. If billing is by the hour, you can make sure that such delays don&#8217;t hurt you. It also makes sure that you get only relevant change requests (since the client is paying for every hour spent).</li>
<li>Pick projects that you like working on and teach you things that can be applied to your own idea. For example, if you are planning to work on an e-commerce portal (or want to add a payment gateway to your existing product), you can pick up a similar project and learn relevant stuff there.</li>
<li>Don&#8217;t mind dirty maintenance jobs as they are short and well-paid. As engineers, we tend to love working from scratch and hate fixing bugs in someone else&#8217;s code. End-to-end product development cannot be delivered in a few sittings unlike a well defined back end work. Also you will make big bucks  in projects that are already live, because  your contribution as a subject matter expert  is extremely important for the company in fixing its product.</li>
<li>On a related note, avoid projects that involve working on the UI. These jobs involve talking to the designer, taking the CEO&#8217;s viewpoint on buttons/boxes and cross browser hell. Compare this to backend work, where you can work all by yourself, whenever you want and finish the job much more quickly. You want to avoid any sort of job that has too many stakeholders.</li>
</ul>
<p><strong>Don&#8217;t grow your consulting business</strong></p>
<p>Once you pick up a project, there are inevitably more such project offers coming your way and most often you will be tempted to hire a couple of freshers and a manager and spin off a consulting business &#8211; an amazingly self sustained money generating machine of a business that requires minimal effort  that can keep funding your product development. If you go down that Utopian path, before long you would realize that most of your time is spent in business development, following up on payments, motivating your employees and other mundane activities. If product company is what you want to build, do not shift focus. Take up just as much  as you can do than sinking into the quagmire of a services business. The cash reserve that you build should be just enough to give a decent runway for growing your startup.</p>
<p><strong>Get Paid</strong></p>
<p>While this looks like the most obvious one, many people make a mistake here. As engineers, we tend to charge based on our needs and not our skill set and its value in the market. Talk to  few of your peers and figure out how much to charge before you quote. Don&#8217;t charge lesser than the market rate and make sure that you get paid. Sometimes, your clients are too busy and paying you may not be the top priority item in their to-do list. Follow up and get paid. If possible, take an advance payment before starting out and decide on milestones for remaining payment.</p>
<p><strong>You can&#8217;t always balance it right</strong></p>
<p>One more setback which is not quite obvious on first glance is the time-sink that can happen due to continuous context switching between consulting projects and your start-up idea. Consulting is going to take your focus away for a while and your startup&#8217;s growth may suffer because of that. The idea is to accept that upfront and not let it bring you down. The last thing you wanna do is to end up demotivated. If you are working all day on consulting projects, there is no point  forcing yourself to work on your startup at night. There is only so much one can code every day and any spare time should be used to reflect upon your  start-up&#8217;s growth and strategy. If you are adventurous, you can also use this break to catch up on your reading or hang out with friends :)</p>
<p>In the end, figure out what works best for you and do it. Idea is to make some money, learn something new and have some fun. When you get back fulltime to your startup, you should be richer and invigorated!</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.prateekdayal.net%2F2009%2F05%2F26%2Ffunding-your-startu-by-consulting-on-the-side%2F';
  addthis_title  = 'Funding+your+startup+by+consulting+on+the+side';
  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/2009/05/26/funding-your-startu-by-consulting-on-the-side/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Google Developer Day October 2008 Bangalore</title>
		<link>http://www.prateekdayal.net/2008/10/18/google-developer-day-october-2008-bangalore/</link>
		<comments>http://www.prateekdayal.net/2008/10/18/google-developer-day-october-2008-bangalore/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 13:00:14 +0000</pubDate>
		<dc:creator>Prateek Dayal</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[activerecord]]></category>

		<guid isPermaLink="false">http://www.prateekdayal.net/blog/?p=106</guid>
		<description><![CDATA[Today was google&#8217;s first developer day in India at Chancery Pavilion, Bangalore. I had registered a couple of weeks back and could get into the otherwise sold out event. Here is a brief of the event. Keynote The keynote by Dr. Prasad talked about how google&#8217;s mission is about improving the Client, Cloud and Connectivity. [...]]]></description>
			<content:encoded><![CDATA[<p>Today was google&#8217;s first developer day in India at Chancery Pavilion, Bangalore. I had registered a couple of weeks back and could get into the otherwise sold out event. Here is a brief of the event.</p>
<p><strong>Keynote</strong></p>
<p>The keynote by Dr. Prasad talked about how google&#8217;s mission is about improving the Client, Cloud and Connectivity. There were a couple of videos about the journey of google and some demos on Chrome (Client), App Engine (Cloud) and Android (Connectivity).</p>
<p><strong>Tech Tracks</strong></p>
<p>I attended two tech tracks</p>
<p><strong>Indic Languages</strong></p>
<p>A demo of two of the indic products (both backed by API)</p>
<ul>
<li>Transliteration</li>
<li>Translation</li>
</ul>
<p>The code is available at <a href="http://code.google.com/apis/ajaxlanguage/" onclick="javascript:pageTracker._trackPageview('/outbound/article/code.google.com');">http://code.google.com/apis/ajaxlanguage/</a></p>
<p><strong>Google Maps API</strong></p>
<p>A demo and overview of the google maps API. Interesting statistics for why maps</p>
<ul>
<li>80% of the world has never moved beyond 20 miles of their birthplace</li>
<li>80% of your expenses are local (even apart from real estate)</li>
<li>You can monetize using adsense for maps (more local than regular adsense)</li>
</ul>
<p>Use of KML (Keyhole map launguage) file. Its a sort of a DTD that lets you paint on a map. It saves development time (since you don&#8217;t have to talk to db etc) and it can be indexed by search engines. You can use KML editors like &#8216;My Maps&#8217; (web based).  You can also use maplet (its like a light weight application overlayed on top of google maps). Users can overlay differenent maplets over the same map.</p>
<p>After the tech tracks, lunch was served. All through the day, there were beverages available outside the rooms. Post lunch there were code labs and I attended the code lab for google maps. The team demo&#8217;d a small map based game and discussed the code. Both the application and the turorial can be found at <a href="http://maps-gdd2008.appspot.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/maps-gdd2008.appspot.com');">http://maps-gdd2008.appspot.com/</a>. After this there was another code lab but I left.</p>
<p>It was an interesting day. Google speakers were pretty awesome and I thing that I found amazing was that they were very keen on getting feedback on their tools and api from the audience.  I also found every googler using chrome and deploying all their sample code on app engine. A true eat your own dog food environment.</p>
<p>Also there were lots of free goodies like a 2 GB USB drive, a free t-shirt, notepads, keyring etc to make the geeks happy :)</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.prateekdayal.net%2F2008%2F10%2F18%2Fgoogle-developer-day-october-2008-bangalore%2F';
  addthis_title  = 'Google+Developer+Day+October+2008+Bangalore';
  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/2008/10/18/google-developer-day-october-2008-bangalore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hosting Review : VpsFarm.com</title>
		<link>http://www.prateekdayal.net/2008/05/13/hosting-review-vpsfarmcom/</link>
		<comments>http://www.prateekdayal.net/2008/05/13/hosting-review-vpsfarmcom/#comments</comments>
		<pubDate>Tue, 13 May 2008 20:11:08 +0000</pubDate>
		<dc:creator>Prateek Dayal</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[vpsfarm]]></category>
		<category><![CDATA[vpsfarm.com]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://prateekdayal.net/blog/?p=67</guid>
		<description><![CDATA[I had written sometime back about why shared hosting is bad for your startup and recommended VPS hosting for any serious web venture. Today, as promised in that post, I am writing a review of VPSFarm.com. VPSFarm is based out of US and while researching for VPS provieders, I found them to be pretty good. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="float: left;" src="http://www.vpsfarm.com/vpsfarm/images/vpsFarm-logo.gif" alt="" width="382" height="121" /></p>
<p>I had written sometime back about why <a href="http://prateekdayal.net/blog/2008/04/16/why-shared-hosting-is-bad-for-your-startup/" >shared hosting is bad</a> for your startup and recommended VPS hosting for any serious web venture. Today, as promised in that post, I am writing a review of <a href="http://vpsfarm.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/vpsfarm.com');">VPSFarm.com</a>. VPSFarm is based out of US and while researching for VPS provieders, I found them to be pretty good. I considered slicehost and other popular VPS choices as well as some cheap dedicated boxes from layeredtech.com etc. This is what I did not like about them</p>
<ul>
<li>Most VPS providers take some time to setup your VPS. This should be mostly fine but there is a delay nevertheless</li>
<li>Providers like Slicehost etc have a waiting time before you can get your VPS. I think after signing up, it took a few weeks before I got an email.</li>
<li>Cheap dedicated boxes have older processors which may be ok for you but I was not so sure about that. Another thing is that they have a regular hard drive and no <a href="http://en.wikipedia.org/wiki/Redundant_array_of_independent_disks" onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');">RAID</a> protection. Even with backups, I think its good to have RAID so that your server does not go down with a drive failure.</li>
<li>I found the RAM being offered everywhere else to be almost half for the same price.</li>
</ul>
<p><!--adsense--></p>
<p>I did not find many reviews of VPSFarm when I was trying to signup and I already had not so great experience with two providers before so I was a little concerned. However I went through their docs online and finally ordered. Somethings that I really liked about them then were</p>
<ul>
<li><span style="color: #000000;">Xen based Virtual Private Servers (from my research I found out that xen is the preferred way)</span></li>
<li>No setup time or fees or annual contracts (pay every month by paypal)</li>
<li>Choice of operating systems (I picked debian as ubuntu was and is still missing)</li>
<li>You can install/reboot/halt VPS using a web based control panel</li>
<li>Bandwidth is unmetered (speed depends on your plan) and RAM/price ratio is awesome</li>
<li>RAID 10 for storage</li>
</ul>
<p>Something that may be of concern to some people are</p>
<ul>
<li>Only one IP address assigned. As far as I know, you cannot currently buy more. This is ok in general but not good  if you want to host DNS. I however recommend <a href="http://prateekdayal.net/blog/2008/04/15/how-to-outsource-on-small-budget/" >outsourcing</a> DNS and emai.</li>
<li>Its not possible to move to a higher or lower plan without some kind of downtime or manually setting up the new VPS. If you are ok with downtime however, they would help you move.</li>
</ul>
<p>So far (last 8 months) my experience with VPSFarm has been awesome. Only once my VPS went down for some 20 minutes but I got an email from them immediately and the issue was fixed. There was once a network outage but it was automatically restored in a minute.  I started out with XEN 1024 plan and I am currently on XEN 2048 plan.</p>
<p><!--adsense--></p>
<p>Do give VPSFarm a try and let us all know your experience too.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.prateekdayal.net%2F2008%2F05%2F13%2Fhosting-review-vpsfarmcom%2F';
  addthis_title  = 'Hosting+Review+%3A+VpsFarm.com';
  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/2008/05/13/hosting-review-vpsfarmcom/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Rails : Accessing session data in models</title>
		<link>http://www.prateekdayal.net/2007/10/25/rails-accessing-session-data-in-models/</link>
		<comments>http://www.prateekdayal.net/2007/10/25/rails-accessing-session-data-in-models/#comments</comments>
		<pubDate>Thu, 25 Oct 2007 11:30:01 +0000</pubDate>
		<dc:creator>Prateek Dayal</dc:creator>
				<category><![CDATA[activerecord]]></category>
		<category><![CDATA[cache_sweeper]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://prateekdayal.net/blog/2007/10/25/rails-accessing-session-data-in-models/</guid>
		<description><![CDATA[MVC architecture is good for keeping your design neat but once in a while you hit a road block and this is one such situtation. If you want to log actions/events in your code and track changes to models, you would want to do that in the activerecord callback hooks like after_save and before_destroy. However [...]]]></description>
			<content:encoded><![CDATA[<p>MVC architecture is good for keeping your design neat but once in a while you hit a road block and this is one such situtation.  If you want to log actions/events in your code and track changes to models, you would want to do that in the activerecord callback hooks like after_save and before_destroy. However these methods have only access to the record that is  affected and not to the session data. Therefore, you cannot log &#8216;who&#8217; made the change.</p>
<p>After some googling around and wasting an hour or so, I found out that the trick is to use cache_sweeper class, which keeps a track of the objects that you ask it to for regenerating caches. You can however use it to keep a track of your changes and log it. Cache Sweeper objects also have access to the session data so you can know &#8216;who&#8217; made changes to your model.</p>
<p><!--adsense--></p>
<p>The process is described further in Rails Recipes book and is quite interesting &#8230; go read on :)</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.prateekdayal.net%2F2007%2F10%2F25%2Frails-accessing-session-data-in-models%2F';
  addthis_title  = 'Rails+%3A+Accessing+session+data+in+models';
  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/10/25/rails-accessing-session-data-in-models/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby on rails learning curve!</title>
		<link>http://www.prateekdayal.net/2007/08/23/ruby-on-rails-learning-curve/</link>
		<comments>http://www.prateekdayal.net/2007/08/23/ruby-on-rails-learning-curve/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 05:25:16 +0000</pubDate>
		<dc:creator>Prateek Dayal</dc:creator>
				<category><![CDATA[activerecord]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[muziboo]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://prateekdayal.net/blog/?p=6</guid>
		<description><![CDATA[The post should be called my ruby on rails learning curve. I just wanted to write about what it was for a person like me to learn ruby on rails and get productive in it and make something like Muziboo.com I was introduced to rails by a cousin of mine when I was trying to [...]]]></description>
			<content:encoded><![CDATA[<p>The post should be called my ruby on rails learning curve. I just wanted to write about what it was for a person like me to learn ruby on rails and get productive in it and make something like <a href="http://muziboo.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/muziboo.com');">Muziboo.com</a></p>
<p>I was introduced to rails by a cousin of mine when I was trying to decide the technology for muziboo. I was intially inclined to use turbogears as I knew a lil bit of python. I had used zope+plone before but I could never really get a grip on that whole system. Once I saw the ruby on rails <a href="http://rubyonrails.org/screencasts" onclick="javascript:pageTracker._trackPageview('/outbound/article/rubyonrails.org');">screencasts</a>, I got really excited and went ahead and tried the book Agile Web Development with Rails.</p>
<p><a href="http://www.amazon.com/Agile-Web-Development-Rails-Programmers/dp/097669400X" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.amazon.com');"><img src="http://ec1.images-amazon.com/images/I/51PP6SQ89CL._AA240_.jpg" title="Agile web development" alt="Agile web development" align="left" height="240" width="240" /></a> I found this book to be pretty good for beginners. I coded almost the entire &#8220;depot&#8221; application that they walk you through in thi book and it really gave me a good knowledge of how basically rails works. I started coding up <a href="http://muziboo.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/muziboo.com');">Muziboo</a> right after this.</p>
<p>After a couple of weeks when I had more specific problem or was looking for some specific information (such as implementing a forum etc), I looked at the book <a href="http://www.amazon.com/Beginning-Ruby-Rails-E-Commerce-Professional/dp/1590597362" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.amazon.com');">Beginning Ruby on Rails Ecommerce</a> which I found to be an excellent read too.</p>
<p>One more thing which really helped me was the amount of tutorial available online on ruby on rails and in particular the <a href="http://railscasts.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/railscasts.com');">Railscasts</a> with Ryan series. For any non-caboose developing in rails, I feel you must subscribe to his feed and check out the videos. I think he posts twice or thrice every week.</p>
<p><!--adsense--></p>
<p>When you actually get down to coding, the <a href="http://api.rubyonrails.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/api.rubyonrails.com');">ruby on rails API</a> is simply irreplaceable. Whatever you are doing, be it activerecords (and specially that) or controllers or anything, do take a look at this. You will find that there are so many things (as in options, methods) other than the most popular ones that you help you achieve a lot. I have never found anything better atleast when it comes to activerecords than the API.</p>
<p><a href="http://www.manning.com/black/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.manning.com');"><img src="http://www.manning.com/black/black_cover150.jpg" height="187" width="150" /></a> I am currently reading <a href="http://www.manning.com/black/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.manning.com');">Ruby for Rails</a> on the recommendation of <a href="http://www.igvita.com/blog" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.igvita.com');">Illya</a> who by the way has a great blog and is again a must subscribe to kinds. I am somehow not finding much time to read this book but so far it has been like an eye opener. If you ever wondered why Ruby &#8216;on&#8217; Rails and not Ruby &#8216;on&#8217; &#8216;something-else&#8217;, you must read this book</p>
<p>This is what I have done to get enough knowledge to be able to code and run <a href="http://muziboo.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/muziboo.com');">Muziboo.com</a>. I will update this post with more information as and when I find something . Please do leave your comments and let me know other useful resources.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.prateekdayal.net%2F2007%2F08%2F23%2Fruby-on-rails-learning-curve%2F';
  addthis_title  = 'Ruby+on+rails+learning+curve%21';
  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/23/ruby-on-rails-learning-curve/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>counter_cache gotcha in activerecord!</title>
		<link>http://www.prateekdayal.net/2007/08/19/counter_cache-gotcha-in-activerecord/</link>
		<comments>http://www.prateekdayal.net/2007/08/19/counter_cache-gotcha-in-activerecord/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 15:47:03 +0000</pubDate>
		<dc:creator>Prateek Dayal</dc:creator>
				<category><![CDATA[activerecord]]></category>
		<category><![CDATA[counter_cache]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://prateekdayal.net/blog/?p=11</guid>
		<description><![CDATA[If you are using counter_cache, you must watch out for this one. I am not sure if this has been fixed in the recent version, but the version that I am using (1.15.3) has the issue If you are using counter_cache (such as in acts_as_commentable as described here), you must make sure that after updating [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using counter_cache, you must watch out for this one. I am not sure if this has been fixed in the recent version, but the version that I am using (1.15.3) has the issue</p>
<p>If you are using counter_cache (such as in acts_as_commentable as described <a href="http://www.hervalfreire.com/blog/2007/05/13/caching-comments-with-acts_as_commentable/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.hervalfreire.com');">here</a>), you must make sure that after updating the counter (in after_create call in this case), you must not save your commentable object (in this case @song) without reloading it, otherwise the counter will be reset back to the value before the increment.</p>
<p>Took me a while to figure this out and I googled after that and found that other people have faced this issue too. You can read more about the error <a href="http://dev.rubyonrails.org/ticket/5050" onclick="javascript:pageTracker._trackPageview('/outbound/article/dev.rubyonrails.org');">here</a></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.prateekdayal.net%2F2007%2F08%2F19%2Fcounter_cache-gotcha-in-activerecord%2F';
  addthis_title  = 'counter_cache+gotcha+in+activerecord%21';
  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/counter_cache-gotcha-in-activerecord/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<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>

