<?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/"
	>

<channel>
	<title>the nobot</title>
	<atom:link href="http://thenobot.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://thenobot.org</link>
	<description>Zack Steinkamp's photos, videos, and writings.</description>
	<pubDate>Wed, 03 Feb 2010 06:12:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mission Peak</title>
		<link>http://thenobot.org/2010/02/02/mission-peak/</link>
		<comments>http://thenobot.org/2010/02/02/mission-peak/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 06:12:03 +0000</pubDate>
		<dc:creator>thenobot</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/?p=228</guid>
		<description><![CDATA[Pop and I went up Mission Peak on a beautiful January morning. We took the &#8220;normal&#8221; path up the Hidden Valley trail then cut across Hidden Valley on the Grove Trail to Horse Heaven Trail to get to the peak. That&#8217;s definitely the best way up and down.
http://www.ebparks.org/files/Mission_Peak_map.pdf
We took Horse Heaven trail to the bottom, [...]]]></description>
			<content:encoded><![CDATA[<p>Pop and I went up Mission Peak on a beautiful January morning. We took the &#8220;normal&#8221; path up the Hidden Valley trail then cut across Hidden Valley on the Grove Trail to Horse Heaven Trail to get to the peak. That&#8217;s definitely the best way up and down.<br />
http://www.ebparks.org/files/Mission_Peak_map.pdf</p>
<p>We took Horse Heaven trail to the bottom, and the last 2/3 was a killer.  It&#8217;s VERY steep after Hidden Valley.</p>
<p>Photos from the hike:<br />
<object width="600" height="600"><param name="flashvars" value="offsite=true&#038;lang=en-us&#038;page_show_url=%2Fphotos%2Fthenobot%2Fsets%2F72157623339383864%2Fshow%2F&#038;page_show_back_url=%2Fphotos%2Fthenobot%2Fsets%2F72157623339383864%2F&#038;set_id=72157623339383864&#038;jump_to="></param><param name="movie" value="http://www.flickr.com/apps/slideshow/show.swf?v=71649"></param><param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/slideshow/show.swf?v=71649" allowFullScreen="true" flashvars="offsite=true&#038;lang=en-us&#038;page_show_url=%2Fphotos%2Fthenobot%2Fsets%2F72157623339383864%2Fshow%2F&#038;page_show_back_url=%2Fphotos%2Fthenobot%2Fsets%2F72157623339383864%2F&#038;set_id=72157623339383864&#038;jump_to=" width="600" height="600"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2010/02/02/mission-peak/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is God a Democracy?</title>
		<link>http://thenobot.org/2010/01/20/is-god-a-democracy/</link>
		<comments>http://thenobot.org/2010/01/20/is-god-a-democracy/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 04:30:42 +0000</pubDate>
		<dc:creator>zs</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/?p=219</guid>
		<description><![CDATA[I firmly believe people are well intentioned.  We really want to be good and do the right thing.  One thing that helps to guide us through life are our beliefs:  Who is in charge?  What does this all mean?  Why are we here?
It is a faith in our own answers to these questions that guides [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-222" src="http://thenobot.org/wp-content/uploads/2010/01/god2-214x300.jpg" alt="god2" width="214" height="300" />I firmly believe people are well intentioned.  We really want to be good and do the right thing.  One thing that helps to guide us through life are our beliefs:  Who is in charge?  What does this all mean?  Why are we here?</p>
<p>It is a faith in our own answers to these questions that guides us through decisions in what to do with our life.  It also acts as a filter on our experiences that colors our perception of those experiences.  We&#8217;re stubborn creatures, and we&#8217;re particularly good at attributing the cause of an event to make it fit within our personal faith structure.</p>
<ul>
<li>&#8220;Haitians made a pact with the devil, therefore there was a giant earthquake there.&#8221;</li>
<li>&#8220;You insulted a man last month so Karma is paying you back with financial woes.&#8221;</li>
<li>&#8220;I helped an old woman cross the street, so God is rewarding me with this job promotion.&#8221;</li>
<li>&#8220;We prayed that the police would find that girl, and they did.  Prayer works!&#8221;</li>
</ul>
<p>A particularly interesting faith-based behavior I&#8217;ve taken note of lately is that of the last example &#8212; prayer.  I can fully get behind the &#8220;let&#8217;s stay on the righteous path&#8221; or &#8220;rub a dub dub, thanks for the grub&#8221; kind of prayer, but I have issues with prayer whose intent is to actually affect change in the world.  This hits the point of the title of this post &#8212; do practitioners of this type of prayer really think that God is a democracy?</p>
<p>For example, I have a friend who was traveling.  She asked her friends on Facebook to pray for a safe flight.</p>
<p>Really?  So without your friends begging for your safe passage over the Pacific, God would smoteth that 757 deep into thine salty waters in a ball of hellfire?  Do rational people actually believe that this is how their all powerful God works?</p>
<p>Another example is praying for a diseased person to be well again.  I&#8217;m all for lending support to people or families going through difficult times, and donating to organizations who are advancing the science of wellness.  But again &#8212; without your votes of prayer, God will decide that not enough people care about this sick person&#8217;s well being and let them wither away in a hospital bed?  Or that now more than ten people have gathered in a circle in a church basement, joined hands, and asked for the sick to be healed (visual: blue beams of light emanating from each person&#8217;s head rising to the heavens in a majestic column of Want), so he is now obligated to banish the tumor from the sick person&#8217;s brain.  Really?</p>
<p>If there is an all powerful supreme being sitting on a cloud somewhere with angels brushing his golden beard, I think the last thing he will do is to run his universe as an episode of American Idol, with only the most voted-on causes moving on to the next round and everything else getting booted from the show.</p>
<p>Please let me know in the comments if I have completely missed a crucial point in understanding this phenomenon.</p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2010/01/20/is-god-a-democracy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tip Tips</title>
		<link>http://thenobot.org/2010/01/20/tip-tips/</link>
		<comments>http://thenobot.org/2010/01/20/tip-tips/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 04:05:48 +0000</pubDate>
		<dc:creator>zs</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/?p=215</guid>
		<description><![CDATA[Divide By Six
This one is simple, but I&#8217;m surprised that not enough people know it.  My tip secret to divide the bill total by six.
Others use shortcuts like &#8220;twice tax&#8221;, but that works out to over 18% now.  Still a decent baseline to round up or down from.  Another shortcut is &#8220;divide by ten then [...]]]></description>
			<content:encoded><![CDATA[<h2>Divide By Six</h2>
<p>This one is simple, but I&#8217;m surprised that not enough people know it.  My tip secret to divide the bill total by six.</p>
<p>Others use shortcuts like &#8220;twice tax&#8221;, but that works out to over 18% now.  Still a decent baseline to round up or down from.  Another shortcut is &#8220;divide by ten then add half again&#8221;.  Divide by six is equivalent to 16.6%.  Let&#8217;s do a few tests to see what is easiest&#8230;</p>
<p>The bill is $24.52.  Divide by six gives you $4 pretty quickly.  Divide by ten and half again is $2.45 then what&#8217;s half of that &#8230; ok $1.20.  $2.45 + $1.20 is $3.65.  That was a lot more work!</p>
<p>The bill is $125.  Divide by six gives you &#8220;Around $20 or $21&#8243;.  Divide by ten and half again is $12.50 plus $6.25, that gets us close to $19.  But how much more effort was that?</p>
<h2>Credit Card Whole Dollars</h2>
<p>WTF is up with people who do all this subtraction when calculating a tip so that the total charged to their credit card is a whole dollar amount?  I mean really people &#8212; what are you trying to accomplish?  Do you keep a running total in your head &#8212; to the nearest PENNY &#8212; of your credit card?  Then the poor server has to do all kinds of penny-precise math and finding of small change on account of your obsession with zeroes.  REALLY!</p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2010/01/20/tip-tips/feed/</wfw:commentRss>
		</item>
		<item>
		<title>25 Hours of Thunderhill</title>
		<link>http://thenobot.org/2009/12/07/25-hours-of-thunderhill/</link>
		<comments>http://thenobot.org/2009/12/07/25-hours-of-thunderhill/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 01:15:16 +0000</pubDate>
		<dc:creator>thenobot</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/?p=212</guid>
		<description><![CDATA[
Photos available here: http://www.flickr.com/photos/thenobot/sets/72157622954200256/
]]></description>
			<content:encoded><![CDATA[<p><object width="600" height="400"><param name="flashvars" value="offsite=true&#038;lang=en-us&#038;page_show_url=%2Fphotos%2Fthenobot%2Fsets%2F72157622954200256%2Fshow%2F&#038;page_show_back_url=%2Fphotos%2Fthenobot%2Fsets%2F72157622954200256%2F&#038;set_id=72157622954200256&#038;jump_to="></param><param name="movie" value="http://www.flickr.com/apps/slideshow/show.swf?v=71649"></param><param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/slideshow/show.swf?v=71649" allowFullScreen="true" flashvars="offsite=true&#038;lang=en-us&#038;page_show_url=%2Fphotos%2Fthenobot%2Fsets%2F72157622954200256%2Fshow%2F&#038;page_show_back_url=%2Fphotos%2Fthenobot%2Fsets%2F72157622954200256%2F&#038;set_id=72157622954200256&#038;jump_to=" width="600" height="400"></embed></object></p>
<p>Photos available here: <a href="http://www.flickr.com/photos/thenobot/sets/72157622954200256/">http://www.flickr.com/photos/thenobot/sets/72157622954200256/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2009/12/07/25-hours-of-thunderhill/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Thanksgiving photos</title>
		<link>http://thenobot.org/2009/11/30/thanksgiving-photos/</link>
		<comments>http://thenobot.org/2009/11/30/thanksgiving-photos/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 04:09:56 +0000</pubDate>
		<dc:creator>zs</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/2009/11/30/thanksgiving-photos/</guid>
		<description><![CDATA[


0035-CRW_1580, originally uploaded by thenobot.


Some pictures from Thanksgiving weekend 2009.
]]></description>
			<content:encoded><![CDATA[<div style="text-align: left; padding: 3px;">
<a href="http://www.flickr.com/photos/thenobot/4137620304/" title="photo sharing"><img src="http://farm3.static.flickr.com/2767/4137620304_1edf457259.jpg" style="border: solid 2px #000000;" alt="" /></a><br />
<br />
<span style="font-size: 0.8em; margin-top: 0px;"><a href="http://www.flickr.com/photos/thenobot/4137620304/">0035-CRW_1580</a>, originally uploaded by <a href="http://www.flickr.com/people/thenobot/">thenobot</a>.</span>
</div>
<p>
Some pictures from Thanksgiving weekend 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2009/11/30/thanksgiving-photos/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Kite at Don Edwards Wildlife Refuge</title>
		<link>http://thenobot.org/2009/11/30/kite-at-don-edwards-wildlife-refuge/</link>
		<comments>http://thenobot.org/2009/11/30/kite-at-don-edwards-wildlife-refuge/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 17:56:47 +0000</pubDate>
		<dc:creator>zs</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/2009/11/30/kite-at-don-edwards-wildlife-refuge/</guid>
		<description><![CDATA[


Kite at Don Edwards Wildlife Refuge, originally uploaded by thenobot.


No kites allowed!
]]></description>
			<content:encoded><![CDATA[<div style="text-align: left; padding: 3px;">
<a href="http://www.flickr.com/photos/thenobot/4144626987/" title="photo sharing"><img src="http://farm3.static.flickr.com/2555/4144626987_e631318b21.jpg" style="border: solid 2px #000000;" alt="" /></a><br />
<br />
<span style="font-size: 0.8em; margin-top: 0px;"><a href="http://www.flickr.com/photos/thenobot/4144626987/">Kite at Don Edwards Wildlife Refuge</a>, originally uploaded by <a href="http://www.flickr.com/people/thenobot/">thenobot</a>.</span>
</div>
<p>
No kites allowed!</p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2009/11/30/kite-at-don-edwards-wildlife-refuge/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Oh it&#8217;s a Bear!</title>
		<link>http://thenobot.org/2009/06/06/oh-its-a-bear/</link>
		<comments>http://thenobot.org/2009/06/06/oh-its-a-bear/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 21:02:43 +0000</pubDate>
		<dc:creator>thenobot</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/?p=205</guid>
		<description><![CDATA[Normal:

Silly:

Lyrics:
Going for a walk
Going over the corn field
Come to a cave
Stretch out your hand
Touch a wet nose
Oh it&#8217;s a bear!
Open the door,
Home at last&#8230;
]]></description>
			<content:encoded><![CDATA[<p>Normal:<br />
<object width="600" height="450"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5033144&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5033144&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object></p>
<p>Silly:<br />
<object width="600" height="450"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5033174&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5033174&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object></p>
<p>Lyrics:<br />
Going for a walk<br />
Going over the corn field<br />
Come to a cave<br />
Stretch out your hand<br />
Touch a wet nose<br />
Oh it&#8217;s a bear!<br />
Open the door,<br />
Home at last&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2009/06/06/oh-its-a-bear/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Satspotting</title>
		<link>http://thenobot.org/2009/04/20/satspotting/</link>
		<comments>http://thenobot.org/2009/04/20/satspotting/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 05:01:34 +0000</pubDate>
		<dc:creator>thenobot</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/?p=199</guid>
		<description><![CDATA[My folks used to live in the Santa Cruz mountains &#8212; where it&#8217;s nice and dark.  They had a hot tub outside.  When I&#8217;d visit, a dip in the tub at night was usually a nice thing.  A couple of times, I&#8217;d luck out and spot a satellite zooming overhead.  It [...]]]></description>
			<content:encoded><![CDATA[<p>My folks used to live in the Santa Cruz mountains &#8212; where it&#8217;s nice and dark.  They had a hot tub outside.  When I&#8217;d visit, a dip in the tub at night was usually a nice thing.  A couple of times, I&#8217;d luck out and spot a satellite zooming overhead.  It was always a neat experience imagining this thing out there that people made &#8212; doing its job, or just caught in orbit around the planet.</p>
<p><img src="http://thenobot.org/wp-content/uploads/2009/04/img_jpg_eps_instruments_medium-300x156.jpg" alt="img_jpg_eps_instruments_medium" title="img_jpg_eps_instruments_medium" width="300" height="156" class="alignright size-medium wp-image-200" />A couple weeks back, I came across a site that publishes the time and path of visible satellites called <a href="http://heavens-above.com/">Heavens Above</a>.  You tell it where you are, and it tells you what you can see.  Simple!  <a href="http://heavens-above.com/allsats.asp?Mag=3.5&#038;lat=37.339&#038;lng=-121.894&#038;loc=San+Jose&#038;alt=24&#038;tz=PST">Here is a page</a> that lists very bright objects visible from San Jose, CA.  If you alter the minimum brightness value (a higher magnitude number), then more items will be listed.  All kinds of satellites are up there.  From communications satellites, to weather tracking devices, to the bodies of rockets used to place satellites in orbit.  During the last Space Shuttle mission, I was able to see it pass overhead while docked to the ISS.  Of course, it was just a pinpoint of light, but it was very cool to know that the little dot of light was housing a group of people.</p>
<p>The couple of hours after sunset and before sunrise are the best times to see satellites, since the satellite will still be illuminated by the sun &#8212; most are 500-1500km above the Earth.  NASA has a tool called <a href="http://science.nasa.gov/Realtime/jtrack/3d/JTrack3d.html">J-Track 3D</a> that helps you visualize just how much is up there, and how far away it is.</p>
<p>So if you&#8217;re looking for something to do on these warm summer nights, what could be better than gazing at stars watching for some of man&#8217;s greatest work to silently slide by overhead.</p>
<p>At the moment, these are the satellites I&#8217;ve seen over the last week:</p>
<ul class="satlist">
<li>2009/04/20 21:13 - <a href="http://heavens-above.com/satinfo.aspx?SatID=19120">Cosmos 1943 Rocket</a></li>
<li>2009/04/19 20:46 - <a href="http://heavens-above.com/satinfo.aspx?SatID=14373">Cosmos 1500 Rocket</a></li>
<li>2009/04/18 21:51 - <a href="http://heavens-above.com/satinfo.aspx?SatID=19120">Cosmos 1943 Rocket</a></li>
<li>2009/04/18 21:39 - <a href="http://heavens-above.com/satinfo.aspx?SatID=25400">Resurs 1-4 Rocket</a></li>
<li>2009/04/15 20:17 - <a href="http://heavens-above.com/satinfo.aspx?SatID=28646">Lacrosse 5</a></li>
<li>2009/04/14 21:12 - <a href="http://heavens-above.com/satinfo.aspx?SatID=25400">Resurs 1-4</a></li>
<li>2009/04/14 21:09 - <a href="http://heavens-above.com/satinfo.aspx?SatID=28646">Lacrosse 5</a></li>
<li>2009/04/14 20:43 - <a href="http://heavens-above.com/satinfo.aspx?SatID=25063">TRMM</a></li>
<li>2009/04/13 20:53 - <a href="http://heavens-above.com/satinfo.aspx?SatID=25063">TRMM</a></li>
<li>2009/04/12 22:14 - <a href="http://heavens-above.com/satinfo.aspx?SatID=29499">MetOp-A</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2009/04/20/satspotting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Transparent Access to a Serialized Column in ActiveRecord</title>
		<link>http://thenobot.org/2009/04/16/transparent-access-to-a-serialized-column-in-activerecord/</link>
		<comments>http://thenobot.org/2009/04/16/transparent-access-to-a-serialized-column-in-activerecord/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 04:28:53 +0000</pubDate>
		<dc:creator>thenobot</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/?p=187</guid>
		<description><![CDATA[I started a job a few weeks ago where we&#8217;re using Ruby on Rails.  I had never used it before, and am starting to learn why it has been able to grow as quickly as it has &#8212; it&#8217;s just damn cool in a lot of ways.
One technique we used a lot in my [...]]]></description>
			<content:encoded><![CDATA[<p>I started a job a few weeks ago where we&#8217;re using Ruby on Rails.  I had never used it before, and am starting to learn why it has been able to grow as quickly as it has &#8212; it&#8217;s just damn cool in a lot of ways.</p>
<p>One technique we used a lot in my previous company was to allocate a column in a database to be a &#8220;catch-all&#8221; for various attributes, in the form of a serialized hash.  The advantage here is that if we want to add an attribute to a table, we would not need to alter the table unless we absolutely had to in order to facilitate SELECTs or ORDERing.  When we&#8217;d read a row from the table, we would de-serialize that column and make that hash available to whatever uses it.  </p>
<p>Ruby on Rails&#8217; ActiveRecord class handles this seamlessly.  Just tell your model to serialize the column like so:</p>
<pre>class MyModelClass < ActiveRecord::Base
  <strong>serialize :data</strong>
end</code></pre>
<p><strong>data</strong> is the name of the column that holds the serialized data.</p>
<p>If you want to enforce the type of data that can be serialized/deserialized, add the type name:</p>
<pre>class MyModelClass < ActiveRecord::Base
  serialize :data<strong>, MyDataClass</strong>
end</pre>
<p>You can then call methods on the object represented in the <strong>data</strong> column by referencing it like this:</p>
<pre>row = MyModelClass.find :first
row.data.foobar</pre>
<p>assuming <strong>MyDataClass</strong> implements a method called <strong>foobar</strong>.</p>
<p>So far so good right?  Well, let&#8217;s say MyDataClass implements a nice object-model of a hash, so calling MyDataClass#keyname will return the value referenced by the key.  You write a bunch of views referencing row.data.foobar or row.data.snafu, but at a later date you decide that you really want to dedicate a column in the database table to the value held by data.foobar.  So you have to visit all your views to be sure you make the change from row.data.foobar to row.foobar.  Crappy!</p>
<p>Wouldn&#8217;t it be nice to just design it from the start so that you could call <strong>row.foobar</strong>?  That way, it&#8217;s at the model&#8217;s discretion whether a bit of data is stored in the serialized column or a &#8220;real&#8221; column.  Nice, right?</p>
<p>Well, it&#8217;s pretty easy to do.  We&#8217;ll define a Mix-In that we&#8217;ll load into certain model classes.  This mix-in will override the <strong>method_missing</strong> and <strong>respond_to?</strong> methods of the class with our own design.  </p>
<p>Here is the content of <strong>lib/model_data_column.rb</strong>:</p>
<pre>##
# Model Data Column Mix-In
# Include this in your data model if you use 'data' as a serialized object.
# This will let you call "model.foo" rather than "model.data.foo"
# to facilitate moving data between the serialized 'data' column
# and real DB columns.
module ModelDataColumn

  def method_missing(method_id, *args)
    self[:data].send(method_id, args) || super
  end

  def respond_to?(method_id, *args)
    self[:data].send(:respond_to?, method_id) ||
      self[:data].send(:has_key?, method_id.id2name) ||
      super
  end

end</pre>
<p><strong>Note:</strong> the class behind your serialized column (<strong>MyDataClass</strong> in this case) needs to implement the method <strong>has_key?</strong>.</p>
<p>Use it in your model like this:</p>
<pre><strong>require 'model_data_column'</strong>

class MyModelClass < ActiveRecord::Base
  <strong>include ModelDataColumn</strong>
  serialize :data, MyDataClass
end</pre>
<p>So now you can call methods in your serialized object column without explicitly referencing the column!  This means the rest of your application does not need to concern itself with how the model has implemented the storage of the data.  It will just work.</p>
<p>There is a danger if the serialized column holds a value with the same key as the name of a database column.  The model will always return the value from the DB column in this case.  However, the benefits of this model are big enough for us where we will trade that for the need to keep tabs on the names of things we are storing.</p>
<p>So now this old code:</p>
<pre>row = MyModelClass.find :first
row.data.foobar</pre>
<p>And this new code:</p>
<pre>row = MyModelClass.find :first
row.foobar</pre>
<p>Will have the same output.  Huzzah!</p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2009/04/16/transparent-access-to-a-serialized-column-in-activerecord/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sluggy!</title>
		<link>http://thenobot.org/2009/03/01/sluggy/</link>
		<comments>http://thenobot.org/2009/03/01/sluggy/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 07:44:45 +0000</pubDate>
		<dc:creator>thenobot</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thenobot.org/?p=183</guid>
		<description><![CDATA[Marina helped me get our vegetable garden beds ready for spring this past weekend.  There were lots and lots of critters living in there, but she was really taken with this slug (&#8221;Sluggy &#8212; she&#8217;s hungry!&#8221;).  So after a night of captivity, I took some photos and a video&#8230;

20090301 Sluggy Has Dinner from [...]]]></description>
			<content:encoded><![CDATA[<p>Marina helped me get our vegetable garden beds ready for spring this past weekend.  There were lots and lots of critters living in there, but she was really taken with this slug (&#8221;Sluggy &#8212; she&#8217;s hungry!&#8221;).  So after a night of captivity, I took some photos and a video&#8230;</p>
<p><object width="600" height="400"><param name="flashvars" value="&#038;offsite=true&amp;lang=en-us&#038;page_show_url=%2Fphotos%2Fthenobot%2Fsets%2F72157614617802138%2Fshow%2F&#038;page_show_back_url=%2Fphotos%2Fthenobot%2Fsets%2F72157614617802138%2F&#038;set_id=72157614617802138&#038;jump_to="></param><param name="movie" value="http://www.flickr.com/apps/slideshow/show.swf?v=67348"></param><param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/slideshow/show.swf?v=67348" allowFullScreen="true" flashvars="&#038;offsite=true&amp;lang=en-us&#038;page_show_url=%2Fphotos%2Fthenobot%2Fsets%2F72157614617802138%2Fshow%2F&#038;page_show_back_url=%2Fphotos%2Fthenobot%2Fsets%2F72157614617802138%2F&#038;set_id=72157614617802138&#038;jump_to=" width="600" height="400"><a href="http://www.flickr.com/photos/thenobot/3318989789/" title="Sluggy in the Spotlight by thenobot, on Flickr"><img src="http://farm4.static.flickr.com/3479/3318989789_345216f01a.jpg" width="500" height="333" alt="Sluggy in the Spotlight" /></a></embed></object></p>
<p><object width="600" height="452"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3429741&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3429741&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="452"></embed></object><br /><a href="http://vimeo.com/3429741">20090301 Sluggy Has Dinner</a> from <a href="http://vimeo.com/thenobot">Zack Steinkamp</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thenobot.org/2009/03/01/sluggy/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.070 seconds -->
