<?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>blog.layer2.org &#187; ruby</title>
	<atom:link href="http://blog.layer2.org/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.layer2.org</link>
	<description>A technical blog</description>
	<lastBuildDate>Sun, 23 May 2010 00:15:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails migration with a list of all United States</title>
		<link>http://blog.layer2.org/2008/01/12/rails-migration-with-a-list-of-all-united-states/</link>
		<comments>http://blog.layer2.org/2008/01/12/rails-migration-with-a-list-of-all-united-states/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 01:58:09 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2008/01/12/rails-migration-with-a-list-of-all-united-states/</guid>
		<description><![CDATA[How many times have you created web applications that use addresses? Since I felt like I wasted the entire 10 minutes it took me to type out this state list, I figured I&#8217;d share it with everyone so that their time wasn&#8217;t equally wasted. Enjoy.
Run this command:
ruby script/generate model State
And put this in db/migrate/XXX_create_states.rb:

class CreateStates [...]]]></description>
			<content:encoded><![CDATA[<p>How many times have you created web applications that use addresses? Since I felt like I wasted the entire 10 minutes it took me to type out this state list, I figured I&#8217;d share it with everyone so that their time wasn&#8217;t equally wasted. Enjoy.</p>
<p>Run this command:</p>
<pre>ruby script/generate model State</pre>
<p>And put this in db/migrate/XXX_create_states.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> CreateStates &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:states</span> <span style="color:#9966CC; font-weight:bold;">do</span> |t|
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:abbreviation</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Alabama'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'AL'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Alaska'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'AK'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Arizona'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'AZ'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Arkansas'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'AR'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'California'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'CA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Colorado'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'CO'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Connecticut'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'CT'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Delaware'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'DE'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'District of Columbia'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'DC'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Florida'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'FL'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Georgia'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'GA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Hawaii'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'HI'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Idaho'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'ID'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Illinois'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'IL'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Indiana'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'IN'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Iowa'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'IA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Kansas'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'KS'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Kentucky'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'KY'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Louisiana'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'LA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Maine'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'ME'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Maryland'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MD'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Massachutsetts'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Michigan'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MI'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Minnesota'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MN'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Mississippi'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MS'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Missouri'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MO'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Montana'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'MT'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Nebraska'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NE'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Nevada'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NV'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'New Hampshire'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NH'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'New Jersey'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NJ'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'New Mexico'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NM'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'New York'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NY'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'North Carolina'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'NC'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'North Dakota'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'ND'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Ohio'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'OH'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Oklahoma'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'OK'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Oregon'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'OR'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Pennsylvania'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'PA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Rhode Island'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'RI'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'South Carolina'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'SC'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'South Dakota'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'SD'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Tennessee'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'TN'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Texas'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'TX'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Utah'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'UT'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Vermont'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'VT'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Virginia'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'VA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Washington'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'WA'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'West Virginia'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'WV'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Wisconsin'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'WI'</span>
    State.<span style="color:#9900CC;">create</span> <span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'Wyoming'</span>, <span style="color:#ff3333; font-weight:bold;">:abbreviation</span> =&gt; <span style="color:#996600;">'WY'</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:states</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2008/01/12/rails-migration-with-a-list-of-all-united-states/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Rails&#8217; attachment_fu, :thumbnail_class and you</title>
		<link>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/</link>
		<comments>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 01:56:23 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/</guid>
		<description><![CDATA[I was having a bit of trouble with attachment_fu that took a while to figure out, so I thought I&#8217;d post my solution for the next person.
I have a Photo model that I&#8217;m using to store pictures. Since attachment_fu will automatically resize, create thumbnails, and store pictures on the file system, it was an easy [...]]]></description>
			<content:encoded><![CDATA[<p>I was having a bit of trouble with attachment_fu that took a while to figure out, so I thought I&#8217;d post my solution for the next person.</p>
<p>I have a Photo model that I&#8217;m using to store pictures. Since attachment_fu will automatically resize, create thumbnails, and store pictures on the file system, it was an easy choice to use it. The things I found I didn&#8217;t like about it:</p>
<ol>
<li>It stores thumbnails as separate records inside the photos table. This means you have to check if thumbnail.nil? each time you display the pictures, and you&#8217;ll have to check parent_id.nil? to count your photos.</li>
<li>You can&#8217;t use your own model validations. For example, I wanted to use</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="ruby">validates_presence_of <span style="color:#ff3333; font-weight:bold;">:name</span>
validates_presence_of <span style="color:#ff3333; font-weight:bold;">:description</span></pre></div></div>

<p>But I&#8217;d always get validation errors because attachment_fu tries to save the thumbnail attributes when it creates or resizes a thumbnail. As you can imagine, this is a major problem.</p>
<h2>:thumbnail_class to the rescue</h2>
<p>Mike Clark&#8217;s <a href="http://clarkware.com/cgi/blosxom/2007/02/24">attachment_fu blog post</a> mentions that you can use the :thumbnail_class argument to separate your model validations and attachment_fu&#8217;s validations. Here&#8217;s how to do it:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> Photo &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  has_many <span style="color:#ff3333; font-weight:bold;">:thumbnails</span>, <span style="color:#ff3333; font-weight:bold;">:foreign_key</span> =&gt; <span style="color:#996600;">'parent_id'</span>
&nbsp;
  has_attachment  <span style="color:#ff3333; font-weight:bold;">:storage</span> =&gt; <span style="color:#ff3333; font-weight:bold;">:file_system</span>,
                          <span style="color:#ff3333; font-weight:bold;">:content_type</span> =&gt; <span style="color:#ff3333; font-weight:bold;">:image</span>,
                          <span style="color:#ff3333; font-weight:bold;">:max_size</span> =&gt; <span style="color:#006666;">10</span>.<span style="color:#9900CC;">megabytes</span>,
                          <span style="color:#ff3333; font-weight:bold;">:resize_to</span> =&gt; <span style="color:#996600;">'640x480'</span>,
                          <span style="color:#ff3333; font-weight:bold;">:thumbnails</span> =&gt; <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:thumb</span> =&gt; <span style="color:#996600;">'100x100'</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,
                          <span style="color:#ff3333; font-weight:bold;">:thumbnail_class</span> =&gt; Thumbnail
&nbsp;
  <span style="color:#008000; font-style:italic;"># Validations</span>
  validates_presence_of <span style="color:#ff3333; font-weight:bold;">:name</span>
  validates_presence_of <span style="color:#ff3333; font-weight:bold;">:description</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Thumbnail &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  belongs_to <span style="color:#ff3333; font-weight:bold;">:photo</span>, <span style="color:#ff3333; font-weight:bold;">:foreign_key</span> =&gt; <span style="color:#996600;">'parent_id'</span>
&nbsp;
  has_attachment  <span style="color:#ff3333; font-weight:bold;">:storage</span> =&gt; <span style="color:#ff3333; font-weight:bold;">:file_system</span>,
                  <span style="color:#ff3333; font-weight:bold;">:content_type</span> =&gt; <span style="color:#ff3333; font-weight:bold;">:image</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The killer for me initially was that I wasn&#8217;t specifying has_attachment in the Thumbnail model. I always got this error:</p>
<pre>
undefined method `temp_path=' for #thumbnail:0xb69a9514</pre>
<p>So save yourself by putting has_attachment in both models. Make sure to define any attachment_fu arguments in your Photo model, and leave the Thumbnail model bare. You&#8217;ll also want to make sure you have the normal attachment_fu schema in <strong>both</strong> models:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:parent_id</span>,  <span style="color:#ff3333; font-weight:bold;">:integer</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:content_type</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:filename</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:thumbnail</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:size</span>, <span style="color:#ff3333; font-weight:bold;">:integer</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:width</span>, <span style="color:#ff3333; font-weight:bold;">:integer</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:height</span>, <span style="color:#ff3333; font-weight:bold;">:integer</span></pre></div></div>

<p>I&#8217;ve found that everything seems to be working as normal going this route. My model validations work and the thumbnails are not polluting the photos table. If you want to find the Photo for a particular Thumbnail, keep in mind that parent_id now refers to the id in the Photo model:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">t = Thumbnail.<span style="color:#9900CC;">find</span> ....  <span style="color:#008000; font-style:italic;"># find your thumbnail</span>
<span style="color:#CC0066; font-weight:bold;">p</span> = Photo.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>t.<span style="color:#9900CC;">parent_id</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>And for the ultimate ease-of-use relationship, just use:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">t = Thumbnail.<span style="color:#9900CC;">find</span> ....  <span style="color:#008000; font-style:italic;"># find your thumbnail</span>
<span style="color:#CC0066; font-weight:bold;">p</span> = t.<span style="color:#9900CC;">photo</span>               <span style="color:#008000; font-style:italic;"># get a photo</span>
<span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">thumbnails</span>              <span style="color:#008000; font-style:italic;"># get all thumbnails</span></pre></div></div>

<p>This works since we defined the has_many relationship in the model.</p>
<p>Let me know if you have any problems with this method or if it helped you!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/11/19/rails-attachment_fu-thumbnail_class-and-you/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to create a lookup table in Ruby on Rails</title>
		<link>http://blog.layer2.org/2007/10/18/how-to-create-a-lookup-table-in-ruby-on-rails/</link>
		<comments>http://blog.layer2.org/2007/10/18/how-to-create-a-lookup-table-in-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 01:02:53 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/10/18/how-to-create-a-lookup-table-in-ruby-on-rails/</guid>
		<description><![CDATA[I&#8217;m a big fan of the Rails way, but sometimes the simple things get you. I like to set up &#8220;lookup tables&#8221; in Rails, ie. tables in the database that hold commonly used, (often) fixed values. For example, if I have a Car model, I might want to define a Car type model. This would [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a big fan of <em>the Rails way</em>, but sometimes the simple things get you. I like to set up &#8220;lookup tables&#8221; in Rails, ie. tables in the database that hold commonly used, (often) fixed values. For example, if I have a Car model, I might want to define a Car type model. This would have two purposes:</p>
<ol>
<li>Give me the ability to associate a type with the Car model (ie. Car.type => &#8217;sport&#8217;)</li>
<li>Pre-load common values into the database (ie. sport, coupe, sedan, etc)</li>
</ol>
<p><span id="more-55"></span></p>
<p>I can accomplish this through a few steps. First, lets generate the lookup table model:</p>
<pre>
$ ruby script/generate model CarType</pre>
<p>We&#8217;ll need to edit the migration under db/migrate/XXX_create_car_types.rb</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> CreateCarTypes &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:car_types</span> <span style="color:#9966CC; font-weight:bold;">do</span> |t|
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'sedan'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'sport'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'coupe'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'truck'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    CarType.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> =&gt; <span style="color:#996600;">'van'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:car_types</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>You&#8217;ll note that I created the <em>name</em> field, and then I just used the create method to produce sample values in the database. This can be an immensely useful technique, especially when deploying a production website &#8211; just run your migrations and those lookup tables are already populated.</p>
<p><strong>Note: </strong>The other technique for populating the database automatically is fixtures. While I think they are great for creating test development data, fixtures fall behind in a production environment. Typically, fixtures will define data like &#8220;Test car 1&#8243; and &#8220;Test car 2&#8243;. This is very useful to during development, but if you have a lot of test data you can crowd your production database pretty quickly. Since there is no mechanism to conditionally load fixture data based on the environment, fixtures lose their appeal. If you must load fixture data into your production database, you may use</p>
<pre>
$ rake RAILS_ENV=production db:fixtures:load</pre>
<p>Second, create the Car model and associate it with a CarType:</p>
<pre>
$ ruby script/generate model Car</pre>

<div class="wp_syntax"><div class="code"><pre class="ruby">Car &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  belongs_to <span style="color:#ff3333; font-weight:bold;">:car_type</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Your Car migration must hold the appropriate car_type_id:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> CreateCars &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    create_table <span style="color:#ff3333; font-weight:bold;">:cars</span> <span style="color:#9966CC; font-weight:bold;">do</span> |t|
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>
      t.<span style="color:#9900CC;">column</span> <span style="color:#ff3333; font-weight:bold;">:car_type_id</span>, <span style="color:#ff3333; font-weight:bold;">:int</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    drop_table <span style="color:#ff3333; font-weight:bold;">:cars</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Then, you can write code like this:</p>
<pre>
c = Car.find(1)
c.car_type
=> #<CarType:0xb70f05c0 @attributes={"name"=>"sedan", "id"=>"1"}>
</pre>
<p>I like to simply even more, so I generally add a method like this to the Car model:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">def</span> type
  car_type.<span style="color:#9900CC;">name</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Resulting in the following:</p>
<pre>
c.type
=> "sedan"</pre>
<p>And thats it!</p>
<p>You might be interested to know that you <em>can</em> add a corresponding has_many to the CarType model to easily find all Cars of a particular type:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">CarType &lt; <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  has_many <span style="color:#ff3333; font-weight:bold;">:cars</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And then call something like:</p>
<pre>
CarType.find(1).cars
=> [#<Car:0xb70f4c88 @attributes={"name"=>"Test car 1", "id"=>"1", "car_type_id"=>"1"}>]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/10/18/how-to-create-a-lookup-table-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Rails&#8217; ruby script/console has tab completion!</title>
		<link>http://blog.layer2.org/2007/10/12/rails-ruby-scriptconsole-has-tab-completion/</link>
		<comments>http://blog.layer2.org/2007/10/12/rails-ruby-scriptconsole-has-tab-completion/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 22:48:53 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/10/12/rails-ruby-scriptconsole-has-tab-completion/</guid>
		<description><![CDATA[While I recently found out about Ruby&#8217;s &#8216;methods&#8217; method, I also found that Rails&#8217; &#8220;ruby script/console&#8221; will do tab completion:

&#62;&#62; a = Array.new
=&#62; []
&#62;&#62; a.
Display all 157 possibilities? (y or n)
a.fetch                         [...]]]></description>
			<content:encoded><![CDATA[<p>While I recently found out about Ruby&#8217;s &#8216;methods&#8217; method, I also found that Rails&#8217; &#8220;ruby script/console&#8221; will do tab completion:</p>
<pre>
&gt;&gt; a = Array.new
=&gt; []
&gt;&gt; a.
Display all 157 possibilities? (y or n)
a.fetch                              a.method                             a.slice
a.__id__                             a.fill                               a.methods                            a.slice!
a.__send__                           a.find                               a.min                                a.sort
a.all?                               a.find_all                           a.nil?                               a.sort!
a.any?                               a.first                              a.nitems                             a.sort_by
a.assoc                              a.flatten                            a.object_id                          a.split
a.at                                 a.flatten!                           a.pack                               a.subclasses_of
a.b64encode                          a.freeze                             a.partition                          a.sum
a.blank?                             a.frozen?                            a.pop                                a.suppress
a.class                              a.gem                                a.pretty_inspect                     a.taguri
a.clear                              a.grep                               a.pretty_print                       a.taguri=
a.clone                              a.group_by                           a.pretty_print_cycle                 a.taint
a.collect                            a.hash                               a.pretty_print_inspect               a.tainted?
a.collect!                           a.id                                 a.pretty_print_instance_variables    a.to_a
a.compact                            a.in_groups_of                       a.private_methods                    a.to_ary
a.compact!                           a.include?                           a.protected_methods                  a.to_default_s
a.concat                             a.index                              a.public_methods                     a.to_formatted_s
a.copy_instance_variables_from       a.index_by                           a.push                               a.to_json
a.daemonize                          a.indexes                            a.rassoc                             a.to_param
a.dclone                             a.indices                            a.reject                             a.to_s
a.decode64                           a.inject                             a.reject!                            a.to_sentence
a.decode_b                           a.insert                             a.remove_subclasses_of               a.to_set
a.delete                             a.inspect                            a.replace                            a.to_xml
a.delete_at                          a.instance_eval                      a.require                            a.to_yaml
a.delete_if                          a.instance_exec                      a.require_gem                        a.to_yaml_properties
a.detect                             a.instance_of?                       a.require_library_or_gem             a.to_yaml_style
a.display                            a.instance_values                    a.respond_to?                        a.transpose
a.dup                                a.instance_variable_get              a.returning                          a.type
a.each                               a.instance_variable_set              a.reverse                            a.uniq
a.each_index                         a.instance_variables                 a.reverse!                           a.uniq!
a.each_with_index                    a.is_a?                              a.reverse_each                       a.unloadable
a.empty?                             a.join                               a.rindex                             a.unshift
a.enable_warnings                    a.kind_of?                           a.select                             a.untaint
a.encode64                           a.last                               a.send                               a.values_at
a.entries                            a.length                             a.shift                              a.with_options
a.eql?                               a.load                               a.silence_stderr                     a.yaml_initialize
a.equal?                             a.map                                a.silence_stream                     a.zip
a.extend                             a.map!                               a.silence_warnings
a.extend_with_included_modules_from  a.max                                a.singleton_methods
a.extended_by                        a.member?                            a.size</pre>
<p>Unfortunately the same thing doesn&#8217;t work for the irb. Of course you can always</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">a.<span style="color:#9900CC;">methods</span>.<span style="color:#9900CC;">sort</span></pre></div></div>

<p>to see the same information.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/10/12/rails-ruby-scriptconsole-has-tab-completion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Mongrel on Ubuntu Feisty with rubygems</title>
		<link>http://blog.layer2.org/2007/10/03/installing-mongrel-on-ubuntu-feisty-with-rubygems/</link>
		<comments>http://blog.layer2.org/2007/10/03/installing-mongrel-on-ubuntu-feisty-with-rubygems/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 04:00:04 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/10/03/installing-mongrel-on-ubuntu-feisty-with-rubygems/</guid>
		<description><![CDATA[When I recently re-installed Ubuntu 7.04 (Feisty), I found that I couldn&#8217;t build the native fastthread gem (a required dependency). If you get this error:

Building native extensions.  This could take a while...
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1

ERROR:  While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem [...]]]></description>
			<content:encoded><![CDATA[<p>When I recently re-installed Ubuntu 7.04 (Feisty), I found that I couldn&#8217;t build the native fastthread gem (a required dependency). If you get this error:<br />
<code><br />
Building native extensions.  This could take a while...<br />
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)<br />
from extconf.rb:1</code><br />
<code><br />
ERROR:  While executing gem ... (RuntimeError)<br />
ERROR: Failed to build gem native extension.<br />
Gem files will remain installed in /var/lib/gems/1.8/gems/fastthread-1.0 for inspection.<br />
</code><br />
then you need the ruby development libraries and the build-essential package. I&#8217;ve found that these commands will make sure mongrel (and rails) is installed correctly:<br />
<code><br />
$ sudo apt-get install ruby1.8-dev rubygems build-essential rails<br />
$ sudo gem install mongrel --include-dependencies<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/10/03/installing-mongrel-on-ubuntu-feisty-with-rubygems/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby has a &#8220;methods&#8221; method to see all available methods</title>
		<link>http://blog.layer2.org/2007/09/28/ruby-has-a-methods-method-to-see-all-available-methods/</link>
		<comments>http://blog.layer2.org/2007/09/28/ruby-has-a-methods-method-to-see-all-available-methods/#comments</comments>
		<pubDate>Fri, 28 Sep 2007 04:42:44 +0000</pubDate>
		<dc:creator>solipsistic</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.layer2.org/2007/09/28/ruby-has-a-methods-method-to-see-all-available-methods/</guid>
		<description><![CDATA[So it turns out that Ruby has a few methods that can really help you figure out what you&#8217;re doing when you&#8217;re working with sparsely documented APIs or you just want a quick reference.
I&#8217;ve used the &#8220;inspect&#8221; method for a long time. You can basically see all of the class members and sometimes other useful [...]]]></description>
			<content:encoded><![CDATA[<p>So it turns out that Ruby has a few methods that can really help you figure out what you&#8217;re doing when you&#8217;re working with <a href="http://www.oneofthewolves.com/2007/03/06/ruby-subversion-bindings-finally-some-documentation/">sparsely documented APIs</a> or you just want a quick reference.</p>
<p>I&#8217;ve used the &#8220;inspect&#8221; method for a long time. You can basically see all of the class members and sometimes other useful information. For example:<br />
<code><br />
irb(main):001:0&gt; s = "My String"<br />
=&gt; "My String"<br />
irb(main):002:0&gt; s.inspect<br />
=&gt; "\"My String\""</code><br />
<code><br />
irb(main):003:0&gt; a = [1, 2, 3]<br />
=&gt; [1, 2, 3]<br />
irb(main):004:0&gt; a.inspect<br />
=&gt; "[1, 2, 3]"<br />
</code></p>
<p>The inspect method can give you a good idea of what data is in a particular object. But what if you want to see all methods an object holds? Well duh&#8230;. use #methods.</p>
<p><code><br />
irb(main):001:0&gt; require 'pp'<br />
=&gt; true<br />
irb(main):002:0&gt; s = "My String"<br />
=&gt; "My String"<br />
irb(main):003:0&gt; pp s.methods.sort<br />
["%",<br />
"*",<br />
"+",<br />
"&lt;",<br />
"&lt;&lt;",<br />
"&lt;=",<br />
"&lt;=&gt;",<br />
"==",<br />
"===",<br />
"=~",<br />
"&gt;",<br />
"&gt;=",<br />
"[]",<br />
"[]=",<br />
"__id__",<br />
"__send__",<br />
"all?",<br />
"any?",<br />
"between?",<br />
"capitalize",<br />
"capitalize!",<br />
"casecmp",<br />
"center",<br />
"chomp",<br />
"chomp!",<br />
"chop",<br />
"chop!",<br />
"class",<br />
"clone",<br />
"collect",<br />
"concat",<br />
"count",<br />
"crypt",<br />
"delete",<br />
"delete!",<br />
"detect",<br />
"display",<br />
"downcase",<br />
"downcase!",<br />
"dump",<br />
"dup",<br />
"each",<br />
"each_byte",<br />
"each_line",<br />
"each_with_index",<br />
"empty?",<br />
"entries",<br />
"eql?",<br />
"equal?",<br />
"extend",<br />
"find",<br />
"find_all",<br />
"freeze",<br />
"frozen?",<br />
"grep",<br />
"gsub",<br />
"gsub!",<br />
"hash",<br />
"hex",<br />
"id",<br />
"include?",<br />
"index",<br />
"inject",<br />
"insert",<br />
"inspect",<br />
"instance_eval",<br />
"instance_of?",<br />
"instance_variable_get",<br />
"instance_variable_set",<br />
"instance_variables",<br />
"intern",<br />
"is_a?",<br />
"kind_of?",<br />
"length",<br />
"ljust",<br />
"lstrip",<br />
"lstrip!",<br />
"map",<br />
"match",<br />
"max",<br />
"member?",<br />
"method",<br />
"methods",<br />
"min",<br />
"next",<br />
"next!",<br />
"nil?",<br />
"object_id",<br />
"oct",<br />
"partition",<br />
"pretty_inspect",<br />
"pretty_print",<br />
"pretty_print_cycle",<br />
"pretty_print_inspect",<br />
"pretty_print_instance_variables",<br />
"private_methods",<br />
"protected_methods",<br />
"public_methods",<br />
"reject",<br />
"replace",<br />
"respond_to?",<br />
"reverse",<br />
"reverse!",<br />
"rindex",<br />
"rjust",<br />
"rstrip",<br />
"rstrip!",<br />
"scan",<br />
"select",<br />
"send",<br />
"singleton_methods",<br />
"size",<br />
"slice",<br />
"slice!",<br />
"sort",<br />
"sort_by",<br />
"split",<br />
"squeeze",<br />
"squeeze!",<br />
"strip",<br />
"strip!",<br />
"sub",<br />
"sub!",<br />
"succ",<br />
"succ!",<br />
"sum",<br />
"swapcase",<br />
"swapcase!",<br />
"taint",<br />
"tainted?",<br />
"to_a",<br />
"to_f",<br />
"to_i",<br />
"to_s",<br />
"to_str",<br />
"to_sym",<br />
"tr",<br />
"tr!",<br />
"tr_s",<br />
"tr_s!",<br />
"type",<br />
"unpack",<br />
"untaint",<br />
"upcase",<br />
"upcase!",<br />
"upto",<br />
"zip"]<br />
=&gt; nil<br />
</code></p>
<p>Useful, huh?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.layer2.org/2007/09/28/ruby-has-a-methods-method-to-see-all-available-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.075 seconds -->
<!-- Cached page served by WP-Cache -->
