<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Take Control of your Field Values with nilify_blanks</title>
	<atom:link href="http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/</link>
	<description>A delicious blend of Ruby and Rails...</description>
	<lastBuildDate>Sun, 03 Jan 2010 16:28:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: benhughes</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-6598</link>
		<dc:creator>benhughes</dc:creator>
		<pubDate>Sun, 03 Jan 2010 16:28:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-6598</guid>
		<description>By default columns are nil anyways, so :default =&gt; nil is really unnecessary.  What this plugin solves is when a form is submitted with a blank value which explicitly gets set as so in the database.  For example if your params hash is:

{ :name =&gt; &quot;Project A&quot;, :description =&gt; &quot;&quot; }

Perhaps you really want the &quot;description&quot; field to be NULL in the database and not &quot;&quot; as it will be by default.</description>
		<content:encoded><![CDATA[<p>By default columns are nil anyways, so :default =&gt; nil is really unnecessary.  What this plugin solves is when a form is submitted with a blank value which explicitly gets set as so in the database.  For example if your params hash is:</p>
<p>{ :name =&gt; &#8220;Project A&#8221;, :description =&gt; &#8220;&#8221; }</p>
<p>Perhaps you really want the &#8220;description&#8221; field to be NULL in the database and not &#8220;&#8221; as it will be by default.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gavin Hughes</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-5185</link>
		<dc:creator>Gavin Hughes</dc:creator>
		<pubDate>Mon, 26 Oct 2009 21:29:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-5185</guid>
		<description>Nice work, Ben.  Exactly what I was looking for.</description>
		<content:encoded><![CDATA[<p>Nice work, Ben.  Exactly what I was looking for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julio Capote</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-3987</link>
		<dc:creator>Julio Capote</dc:creator>
		<pubDate>Mon, 31 Aug 2009 20:41:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-3987</guid>
		<description>Perhaps I&#039;m confused, but what&#039;s wrong with just having :default =&gt; nil? in your migrations?</description>
		<content:encoded><![CDATA[<p>Perhaps I&#8217;m confused, but what&#8217;s wrong with just having :default =&gt; nil? in your migrations?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: benhughes</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-2897</link>
		<dc:creator>benhughes</dc:creator>
		<pubDate>Thu, 28 May 2009 02:21:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-2897</guid>
		<description>Ah great catch - I&#039;ve changed the plugin to only activate if the table exists. Thanks!</description>
		<content:encoded><![CDATA[<p>Ah great catch &#8211; I&#8217;ve changed the plugin to only activate if the table exists. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-2884</link>
		<dc:creator>Andreas</dc:creator>
		<pubDate>Tue, 26 May 2009 21:50:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-2884</guid>
		<description>I was looking for exactly this behavior and it is really working well in general.  Unfortunately, I ran into a catch 22 situation.  When running my migrations, I get the following error - tables don&#039;t exist yet.  Only commenting the nilify_blanks line gets me passed this issue. Here is the relevant stack trace fragment:

Mysql::Error: Table &#039;ll_prd.organizations&#039; doesn&#039;t exist: SHOW FIELDS FROM `organizations`
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log&#039;
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:309:in `execute&#039;
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:440:in `columns&#039;
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1220:in `columns&#039;
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1239:in `content_columns&#039;
/Library/Ruby/Gems/1.8/gems/railsgarden-nilify_blanks-0.1.1/lib/nilify_blanks.rb:24:in `nilify_blanks&#039;</description>
		<content:encoded><![CDATA[<p>I was looking for exactly this behavior and it is really working well in general.  Unfortunately, I ran into a catch 22 situation.  When running my migrations, I get the following error &#8211; tables don&#8217;t exist yet.  Only commenting the nilify_blanks line gets me passed this issue. Here is the relevant stack trace fragment:</p>
<p>Mysql::Error: Table &#8216;ll_prd.organizations&#8217; doesn&#8217;t exist: SHOW FIELDS FROM `organizations`<br />
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log&#8217;<br />
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:309:in `execute&#8217;<br />
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:440:in `columns&#8217;<br />
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1220:in `columns&#8217;<br />
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1239:in `content_columns&#8217;<br />
/Library/Ruby/Gems/1.8/gems/railsgarden-nilify_blanks-0.1.1/lib/nilify_blanks.rb:24:in `nilify_blanks&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: benhughes</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-2084</link>
		<dc:creator>benhughes</dc:creator>
		<pubDate>Mon, 09 Mar 2009 19:22:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-2084</guid>
		<description>Looks like there was a problem with this working in gem mode; this should be solved and now working as of the latest version (0.1.1) - just update the gem and it should work now.</description>
		<content:encoded><![CDATA[<p>Looks like there was a problem with this working in gem mode; this should be solved and now working as of the latest version (0.1.1) &#8211; just update the gem and it should work now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gindogg</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-1969</link>
		<dc:creator>gindogg</dc:creator>
		<pubDate>Fri, 27 Feb 2009 23:12:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-1969</guid>
		<description>I followed the readme install instructions and the gem shows up when I run &quot;gem list.&quot;  However, I receive &quot;undefined local variable or method `nilify_blanks&#039;&quot;.  Not sure what I&#039;m missing.</description>
		<content:encoded><![CDATA[<p>I followed the readme install instructions and the gem shows up when I run &#8220;gem list.&#8221;  However, I receive &#8220;undefined local variable or method `nilify_blanks&#8217;&#8221;.  Not sure what I&#8217;m missing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed W</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-1794</link>
		<dc:creator>Ed W</dc:creator>
		<pubDate>Sun, 25 Jan 2009 23:22:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-1794</guid>
		<description>Better also to remove the trinary logic and make fields NOT NULL unless it&#039;s particularly useful...</description>
		<content:encoded><![CDATA[<p>Better also to remove the trinary logic and make fields NOT NULL unless it&#8217;s particularly useful&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-1730</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Fri, 09 Jan 2009 17:28:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-1730</guid>
		<description>Another plugin for doing this is strip_attributes</description>
		<content:encoded><![CDATA[<p>Another plugin for doing this is strip_attributes</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: benhughes</title>
		<link>http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/comment-page-1/#comment-1729</link>
		<dc:creator>benhughes</dc:creator>
		<pubDate>Thu, 08 Jan 2009 23:17:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2009/01/07/take-control-of-your-field-values-with-nilify_blanks/#comment-1729</guid>
		<description>Jay - if you use this plugin on your model, by default all fields that respond to blank? and return true for it will be converted to nils.  Any fields that can &quot;legitimately&quot; be blank must be excepted from the columns like this: nilify_blanks :except =&gt; [:can_be_blank].  

Also, to be clear, *all* the fields that get converted are checked upon every save, regardless of whether a value has or has not been set.  In other words if you have a blank field in the model then have a form that does *not* include that field (hence no key provided for it in update_attributes, for example), that blank field will still be converted to nil.  It works as a before_save filter, not by overriding the mutators.</description>
		<content:encoded><![CDATA[<p>Jay &#8211; if you use this plugin on your model, by default all fields that respond to blank? and return true for it will be converted to nils.  Any fields that can &#8220;legitimately&#8221; be blank must be excepted from the columns like this: nilify_blanks :except => [:can_be_blank].  </p>
<p>Also, to be clear, *all* the fields that get converted are checked upon every save, regardless of whether a value has or has not been set.  In other words if you have a blank field in the model then have a form that does *not* include that field (hence no key provided for it in update_attributes, for example), that blank field will still be converted to nil.  It works as a before_save filter, not by overriding the mutators.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
