<?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>Michael Klett &#187; Rails</title>
	<atom:link href="http://michaelklett.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaelklett.com</link>
	<description></description>
	<lastBuildDate>Sun, 27 Sep 2009 18:12:14 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Huge Dropbox Cache File</title>
		<link>http://michaelklett.com/2009/09/27/huge-dropbox-cache-file/</link>
		<comments>http://michaelklett.com/2009/09/27/huge-dropbox-cache-file/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 18:10:27 +0000</pubDate>
		<dc:creator>Michael Klett</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://michaelklett.com/?p=22</guid>
		<description><![CDATA[Recently, I noticed that my hard drive usage had suddenly doubled. Using OmniDiskSweeper as a tool to quickly visualize my folder and file sizes, I discovered that my Dropbox cache file (in /Users/&#60;username&#62;/.dropbox/cache) had grown to 26GB!  There seem to be some issues with cache management in Dropbox, but my usage also probably didn&#8217;t fit [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I noticed that my hard drive usage had suddenly doubled. Using <a href="http://www.omnigroup.com/applications/omnidisksweeper/">OmniDiskSweeper</a> as a tool to quickly visualize my folder and file sizes, I discovered that my <a href="https://www.getdropbox.com/">Dropbox</a> cache file (in /Users/&lt;username&gt;/.dropbox/cache) had grown to 26GB!  There seem to be some issues with cache management in Dropbox, but my usage also probably didn&#8217;t fit a normal use case. What behavior of mine caused this, and what did I do about it?</p>
<h3>Background</h3>
<p>I write code on 2 different machines: my (aging) MacBook Pro and a 24&#8243; iMac.  Looking back, I should have replaced the MacBook and added a 24&#8243; monitor instead of buying the iMac, but that&#8217;s hindsight&#8230;</p>
<p>Anyway, I was actually keeping certain Ruby on Rails projects in git in folders <em>in Dropbox</em>.  Yes, I know this is slightly redundant when using a version control system, and I caught some flak for this from a colleague.  But the convenience was amazing. I often get up from my iMac mid-coding session and end up plopping down someplace else with the laptop and resuming.  It is so nice not to have to commit, push, and pull every time this happens.  In fact, sometimes I don&#8217;t even completely plan it; I&#8217;ll leave the house for an errand, and end up staying out and coding from a coffee shop.  Since I rarely leave home without my laptop (which I&#8217;m beginning to think is a character flaw) this works well for me.</p>
<h3>Syncing a git repo through Dropbox</h3>
<p>Up until now, I&#8217;ve had very few problems syncing a git repository through Dropbox.  The only real issue I ever encountered was that the file permissions would change on executable files. Newly created files with 755 permissions would sometimes turn to 644 when synced to the other machine.  Doing a fresh git checkout on just these files would restore the permissions and they would stay correct.  (I never bothered trying to solve this problem permanently).</p>
<p>Once, I actually ended up with a conflict in the git index, but it was easily resolved since Dropbox doesn&#8217;t blow away any files in this case (it just appends the name with &#8220;(conflicted copy)&#8221;.</p>
<h3>Enter Autospec</h3>
<p>The other day, I begin using <a href="http://wiki.github.com/dchelimsky/rspec/autotest-integration">autospec</a> combined with <a href="http://wiki.github.com/dchelimsky/rspec/spork-autospec-pure-bdd-joy">spork</a> (highly recommended by the way) in my testing.  Something about this process generates lots of log files (temporary or otherwise, I haven&#8217;t checked).  While this was going on, the Dropbox cache files on the <em>other</em> computer where silently growing HUGE.</p>
<p>By the time I realized it, the cache files for a 4 day period had grown in size from something normal to 26GB!!!</p>
<h3>I surrender</h3>
<p>I probably should take the time to figure out exactly what&#8217;s going on, maybe even give the Dropbox guys some pointers on how to replicate this situation.  I still might &#8211; I still love Dropbox and it has its place in my computing.</p>
<p>But for now, I&#8217;m going to take my git repos out my Dropbox.  I was feeling guilty about it anway &#8211; it felt like I was doing something dirty &#8211; so this was the straw that broke the camel&#8217;s back.</p>
<p>As for reclaiming the space?  Its safe to delete your Dropbox cache files.  Just shut down Dropbox, delete the cache files (individual folders or the while ~/.dropbox/cache folder) and then restart Dropbox.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelklett.com/2009/09/27/huge-dropbox-cache-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing the Rails field_error_proc on a per-controller or per-action basis</title>
		<link>http://michaelklett.com/2008/02/02/changing-the-rails-field_error_proc-on-a-per-controller-or-per-action-basis/</link>
		<comments>http://michaelklett.com/2008/02/02/changing-the-rails-field_error_proc-on-a-per-controller-or-per-action-basis/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 23:09:00 +0000</pubDate>
		<dc:creator>Michael Klett</dc:creator>
				<category><![CDATA[Home]]></category>
		<category><![CDATA[radiant]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://michaelklett.com/2008/02/03/changing-the-rails-field_error_proc-on-a-per-controller-or-per-action-basis</guid>
		<description><![CDATA[So we know we can change how rails displays errors in forms with fields that fail validation.  I came across a reason to need to change the ActionView::Base.field_error_proc temporarily, and then set it back&#8230; sort of like having different values for the field_error_proc in different places.  I came across this post that basically [...]]]></description>
			<content:encoded><![CDATA[<p>So we know <a href="http://www.jroller.com/obie/entry/customizing_how_rails_validation_errors">we can change how rails displays errors</a> in forms with fields that fail validation.  I came across a reason to need to change the <code>ActionView::Base.field_error_proc</code> temporarily, and then set it back&#8230; sort of like having different values for the <code>field_error_proc</code> in different places.  I came across <a href="http://pivots.pivotallabs.com/users/felix/blog/articles/267-applying-different-error-display-styles">this post</a> that basically uses a helper method to store the old <code>field_proc_error</code> value, change it, then change it back.  Realizing that I could do that brought me to a solution that works better in my case.</p>
<p>My solution is to use an around filter on my controller and a custom class.  This way, I can set how form validation errors are displayed on entire controllers or certain actions.</p>
<p>I created a new file called <code>field_error_proc_changer.rb</code> in my <code>lib</code> directory as follows:</p>
<pre><code>class FieldErrorProcChanger
  def initialize(proc)
    @new_proc = proc
  end

  # This will run before the action. Returning false
  # aborts the action.
  def before(controller)
    @old_proc = ActionView::Base.field_error_proc
    ActionView::Base.field_error_proc = @new_proc
    true
  end

  # This will run after the action if and only if
  # before returned true.
  def after(controller)
    ActionView::Base.field_error_proc = @old_proc
  end
end
</code></pre>
<p>Now, you can replace the existing <code>field_error_proc</code> using a normal <a href="http://api.rubyonrails.org/classes/ActionController/Filters/ClassMethods.html#M000316">around_filter</a></p>
<pre><code>class RandomController &lt; ApplicationController

  around_filter FieldErrorProcChanger.new(
    Proc.new {|html_tag, instance| "#{html_tag}"}
  )

  def index
    foo = bar
  end
end
</code></pre>
<p>Or on only certain actions like</p>
<pre><code>  around_filter FieldErrorProcChanger.new(
    Proc.new {|html_tag, instance| "#{html_tag}"}
  ), <img src='http://michaelklett.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly =&gt; [:index]
</code></pre>
<p>The value for <code>field_error_proc</code> I&#8217;m showing actually doesn&#8217;t add anything to the field with validation errors (I&#8217;m using a custom form builder that adds special classes to fields with errors, so I don&#8217;t need any html added).  But, you could add a fancier proc too:</p>
<pre><code>around_filter FieldErrorProcChanger.new(
  Proc.new  do |html_tag, instance|
    html = &amp;#8220;&amp;#8221;
    html &lt;&lt; %{&lt;div class="ridiculous_construct"&gt;}
    html &lt;&lt; %{&lt;span&gt;There&amp;#8217;s an error over here!&lt;/span&gt;}
    html &lt;&lt; %{#{html_tag}&lt;/div&gt;}
  end
)
</code></pre>
<p>Why would you want to do this?  In my case, I&#8217;m adding an extension to the Radiant CMS. My extension has an administrative interface, and my forms aren&#8217;t exactly like the default Radiant forms.  Radiant sets its own <code>field_error_proc</code>, which I don&#8217;t want in my controllers, but I don&#8217;t want to change the way the native Radiant admin works or looks.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelklett.com/2008/02/02/changing-the-rails-field_error_proc-on-a-per-controller-or-per-action-basis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using ActionMailer with SMTP in a development environment</title>
		<link>http://michaelklett.com/2007/06/25/using-actionmailer-with-smtp-in-a-development-environment/</link>
		<comments>http://michaelklett.com/2007/06/25/using-actionmailer-with-smtp-in-a-development-environment/#comments</comments>
		<pubDate>Mon, 25 Jun 2007 12:46:00 +0000</pubDate>
		<dc:creator>Michael Klett</dc:creator>
				<category><![CDATA[Home]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://michaelklett.com/2007/06/25/using-actionmailer-with-smtp-in-a-development-environment</guid>
		<description><![CDATA[I just ran in to a problem where I wanted to use SMTP delivery for an ActionMailer mail in a Rails app running on my local development machine.  When I sent the email, it seemed to send with no problems (no errors raised) but it didn&#8217;t get delivered and I couldn&#8217;t find it.  [...]]]></description>
			<content:encoded><![CDATA[<p>I just ran in to a problem where I wanted to use SMTP delivery for an ActionMailer mail in a Rails app running on my local development machine.  When I sent the email, it seemed to send with no problems (no errors raised) but it didn&#8217;t get delivered and I couldn&#8217;t find it.  So I changed my authentication credentials to supply a bad password, and still it didn&#8217;t complain.  Ah, there&#8217;s the problem.  It really should complain, with a</p>
<pre><code>Net::SMTPAuthenticationError (535 Incorrect authentication data)
</code></pre>
<p>The Rails app needs to be restarted to pick up the configuration settings.  This was on a Locomotive environment with Rails 1.2.3.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelklett.com/2007/06/25/using-actionmailer-with-smtp-in-a-development-environment/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
