Robby on Rails: Master, console, and servant part twothoughts.sort_by{|t| t[:topic]}.collect tag:www.robbyonrails.com,2005:TypoTypo2006-09-05T22:12:48-04:00Robby Russellurn:uuid:9935c416cdd3d27d45838e651ead24ab2005-10-03T23:54:00-04:002006-09-05T22:12:48-04:00Master, console, and servant part two<p>This is a brief addition to the post from a few days ago, <a href="http://www.robbyonrails.com/articles/2005/10/01/master-console-and-servant">Master, console, and servant.</a></p>
<p>Noradio on <span class="caps">IRC</span> pointed out one thing that I did not mention in my previous blog entry… that you can bind a subsession of <code>irb</code> to a specific object. What??</p>
<p>Okay, let me explain this a bit more. Instead of always setting a variable to hold an instance of an object, you can be a bit more creative with <code>irb</code>.</p>
<p>I present…</p>
<p><img src="http://www.planetargon.com/files/~robby/console_irb_bind_objects.jpg" alt="" /></p>
<p>So, for example. You can perform the following in <code>script/console</code>.</p>
<typo:code lang="ruby">
irb Model.find(4)
name
</type:code>
<p>If there is an attribute/method called name in your model, then it will call it there. See my screen shot for some more details of how I used the <code>jobs</code> and <code>fg #</code> commands to switch jobs…. and I even found out what happens when you attempt to switch to the current thread. :-)</p>
<p>Until next time…</p><p>This is a brief addition to the post from a few days ago, <a href="http://www.robbyonrails.com/articles/2005/10/01/master-console-and-servant">Master, console, and servant.</a></p>
<p>Noradio on <span class="caps">IRC</span> pointed out one thing that I did not mention in my previous blog entry… that you can bind a subsession of <code>irb</code> to a specific object. What??</p>
<p>Okay, let me explain this a bit more. Instead of always setting a variable to hold an instance of an object, you can be a bit more creative with <code>irb</code>.</p>
<p>I present…</p>
<p><img src="http://www.planetargon.com/files/~robby/console_irb_bind_objects.jpg" alt="" /></p>
<p>So, for example. You can perform the following in <code>script/console</code>.</p>
<typo:code lang="ruby">
irb Model.find(4)
name
</type:code>
<p>If there is an attribute/method called name in your model, then it will call it there. See my screen shot for some more details of how I used the <code>jobs</code> and <code>fg #</code> commands to switch jobs…. and I even found out what happens when you attempt to switch to the current thread. :-)</p>
<p>Until next time…</p>