<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Robby on Rails: Tag tutorial</title>
    <link>http://www.robbyonrails.com/articles/tag/tutorial</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>thoughts.sort_by{|t| t[:topic]}.collect </description>
    <item>
      <title>RSpec: It Should Behave Like</title>
      <description>&lt;p&gt;I was going through an older project of ours and cleaning up some specs and noticed how often we were doing the same thing in several places. When we started the project, we didn&amp;#8217;t get the benefits of shared groups. Now that we have some time to go through and update some of our older specs, I&amp;#8217;ve been trying to take advantage of the features currently available in &lt;a href="http://rspec.info/"&gt;RSpec&lt;/a&gt;. One feature that I haven&amp;#8217;t seen a lot of mention of by people is shared groups, so I thought I&amp;#8217;d take a few minutes to write up a quick intro to using it.&lt;/p&gt;


	&lt;p&gt;To pick some low-hanging fruit, let&amp;#8217;s take an all-too-familiar method, which you might be familiar with&amp;#8230; &lt;code&gt;login_required&lt;/code&gt;. Sound familiar? Have you found yourself &lt;em&gt;stubbing&lt;/em&gt; &lt;code&gt;login_required&lt;/code&gt; over and over throughout your specs?&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;describe&lt;/span&gt; &lt;span class="constant"&gt;Admin&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;DohickiesController&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;index&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;

  &lt;span class="ident"&gt;before&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:each&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
    &lt;span class="ident"&gt;controller&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;stub!&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:login_required&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="constant"&gt;Dohicky&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;should_receive&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:paginate&lt;/span&gt; &lt;span class="punct"&gt;).&lt;/span&gt;&lt;span class="ident"&gt;and_return&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="constant"&gt;Array&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="ident"&gt;get&lt;/span&gt; &lt;span class="symbol"&gt;:index&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

 &lt;span class="punct"&gt;...&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;If you&amp;#8217;re requiring that a user should be logged in when interacting with most of the application (as in the case of an administration section/namespace), you might want to consolidate some of your work into one shared specification group. The basic premise behind this is that you can write a typical &lt;code&gt;describe&lt;/code&gt; block and load it into any other spec groups that you need. For example, in our case, we&amp;#8217;ll need to stub &lt;code&gt;login_required&lt;/code&gt; in several places. We can set this up in one shared group and reference it wherever necessary.&lt;/p&gt;


	&lt;p&gt;For example, here is what we&amp;#8217;ll start off with.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;describe&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;an admin user is signed in&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;before&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:each&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
    &lt;span class="ident"&gt;controller&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;stub!&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:login_required&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;describe&lt;/span&gt; &lt;span class="constant"&gt;Admin&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;DohickiesController&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;index&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="punct"&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;However, the new describe block isn&amp;#8217;t accessible from the block at the bottom of the example&amp;#8230; yet. To do this, we just need to pass the option: &lt;code&gt;:shared =&amp;gt; true&lt;/code&gt; as you&amp;#8217;ll see in the following example.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;describe&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;an admin user is signed in&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; &lt;span class="symbol"&gt;:shared&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="constant"&gt;true&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;before&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:each&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
    &lt;span class="ident"&gt;controller&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;stub!&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:login_required&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Great, now we can reference it by referring to it with: &lt;code&gt;it_should_behave_like SharedGroupName&lt;/code&gt;. In our example above, this would look like:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;describe&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;an admin user is signed in&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;before&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:each&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
    &lt;span class="ident"&gt;controller&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;stub!&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:login_required&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;describe&lt;/span&gt; &lt;span class="constant"&gt;Admin&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;DohickiesController&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;index&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;it_should_behave_like&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;an admin user is signed in&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;

  &lt;span class="ident"&gt;before&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:each&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
    &lt;span class="constant"&gt;Dohicky&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;should_receive&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:paginate&lt;/span&gt; &lt;span class="punct"&gt;).&lt;/span&gt;&lt;span class="ident"&gt;and_return&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="constant"&gt;Array&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="ident"&gt;get&lt;/span&gt; &lt;span class="symbol"&gt;:index&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

 &lt;span class="punct"&gt;...&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;

&lt;span class="ident"&gt;describe&lt;/span&gt; &lt;span class="constant"&gt;Admin&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;DohickiesController&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;it_should_behave_like&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;an admin user is signed in&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;

  &lt;span class="ident"&gt;before&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:each&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
    &lt;span class="attribute"&gt;@dohicky&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;mock_model&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="constant"&gt;Dohicky&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="constant"&gt;Dohicky&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;should_receive&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="symbol"&gt;:new&lt;/span&gt; &lt;span class="punct"&gt;).&lt;/span&gt;&lt;span class="ident"&gt;and_return&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt; &lt;span class="attribute"&gt;@dohicky&lt;/span&gt; &lt;span class="punct"&gt;)&lt;/span&gt;
    &lt;span class="ident"&gt;get&lt;/span&gt; &lt;span class="symbol"&gt;:new&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

  &lt;span class="punct"&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;That&amp;#8217;s it! Pretty simple, eh? We can now reference this shared group in any describe blocks that we want to. A benefit to this approach is that we can make change the authentication system (say, we decide to switch it entirely and/or even just change method names, set any other prerequisites necessary when an admin is signed in), we&amp;#8217;ll have a single place to change in our specs. (&lt;strong&gt;tip:&lt;/strong&gt; you can put these in your &lt;code&gt;spec_helper&lt;/code&gt; file)&lt;/p&gt;


	&lt;p&gt;You can learn more about &lt;code&gt;it_should_behave_like&lt;/code&gt; and other helpful features on the &lt;a href="http://rspec.info/documentation/"&gt;RSpec documentation site&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;If you have any suggestions on better ways of handling things like this, please follow up and share your solutions. I&amp;#8217;m always looking to sharpen my tools. :-)&lt;/p&gt;


	&lt;h3&gt;Update&lt;/h3&gt;


	&lt;p&gt;In response, &lt;a href="http://brynary.com/"&gt;Bryan Helmkamp&lt;/a&gt; suggests that a better solution is to define a method in our specs like, for example: &lt;code&gt;build_mock_user_and_login&lt;/code&gt;. then calling it in our &lt;code&gt;before(:each)&lt;/code&gt;. So, maybe the approach above isn&amp;#8217;t the most ideal method but I did wantt o draw some attention to &lt;code&gt;it_should_behave_like&lt;/code&gt;. I suppose that I need a better example.. another post, perhaps? :-)&lt;/p&gt;


	&lt;p&gt;Also, Ed Spencer has posted an article titled, &lt;a href="http://edspencer.net/2008/08/drying-up-your-crud-controller-rspecs.html"&gt;DRYing up your &lt;span class="caps"&gt;CRUD&lt;/span&gt; controller RSpecs&lt;/a&gt;, which will introduce you mor to &lt;code&gt;it_should_behave_like&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;Thanks for feedback people!&lt;/p&gt;


	&lt;h3&gt;Related Posts&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://www.robbyonrails.com/articles/2007/02/13/be-careful-that-you-dont-stub-your-big-toe"&gt;Be Careful that you don&amp;#8217;t Stub your Big Toe&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://www.robbyonrails.com/articles/2007/08/02/spec-your-views"&gt;Spec Your Views&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
</description>
      <pubDate>Tue, 19 Aug 2008 21:47:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:769c7a25-afa3-40aa-aeb4-98c2ac61115a</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2008/08/19/rspec-it-should-behave-like</link>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>Programming</category>
      <category>development</category>
      <category>rspec</category>
      <category>controllers</category>
      <category>rubyonrails</category>
      <category>rails</category>
      <category>agile</category>
      <category>tutorial</category>
      <category>specs</category>
      <category>code</category>
    </item>
    <item>
      <title>Campfire messages in Growl</title>
      <description>&lt;p&gt;Our team has slowly been transitioning from &lt;span class="caps"&gt;IRC&lt;/span&gt; to &lt;a href="http://campfirenow.com"&gt;Campfire&lt;/a&gt; (iPhone interface helped with this decision) for internal team discussions. Earlier today, I decided to setup Campfire to connect to Growl. There are a few scripts to do this, but I figured that I&amp;#8217;d consolidate the steps here for my teammates and share with everyone else in the process.&lt;/p&gt;


	&lt;h2&gt;Step 1: Get stuff installed&lt;/h2&gt;


	&lt;p&gt;You&amp;#8217;ll need to install the following programs on &lt;span class="caps"&gt;OSX&lt;/span&gt;.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://growl.info"&gt;Growl&lt;/a&gt; (install and run it)&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://fluidapp.com/"&gt;Fluid.app&lt;/a&gt; (run a web site in it&amp;#8217;s own desktop app)
	&lt;ul&gt;
	&lt;li&gt;Follow instructions on their homepage (requires restart of Safari)&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h2&gt;Step 2: Setup Campfire&lt;/h2&gt;


	&lt;p&gt;Once you have everything installed, you can go ahead and create your Campfire Fluid application. You&amp;#8217;ll need to provide your Campfire &lt;span class="caps"&gt;URL&lt;/span&gt; and a name for the application.&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/8e9e/campfire-fluid"&gt;&lt;img src="http://img.skitch.com/20080305-gxjxd3m7798mwq88mrfmktwh8u.preview.jpg" alt="Campfire Fluid" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080"&gt;Uploaded with &lt;a href="http://plasq.com/"&gt;plasq&lt;/a&gt;&amp;#8217;s &lt;a href="http://skitch.com"&gt;Skitch&lt;/a&gt;!&lt;/span&gt;&lt;/div&gt;

	&lt;p&gt;Once you get it running, you should be able to run your Campfire application in it&amp;#8217;s own window.&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/8e9u/campfire-blogging"&gt;&lt;img src="http://img.skitch.com/20080305-fpbmsgncwxrpx2yuq7e4fqn5e3.preview.jpg" alt="Campfire: Blogging" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080"&gt;Uploaded with &lt;a href="http://plasq.com/"&gt;plasq&lt;/a&gt;&amp;#8217;s &lt;a href="http://skitch.com"&gt;Skitch&lt;/a&gt;!&lt;/span&gt;&lt;/div&gt;

	&lt;h3&gt;Step 3: Install the Campfire Growl script for GreaseKit&lt;/h3&gt;


	&lt;p&gt;Next, you&amp;#8217;ll want to install &lt;a href="http://userscripts.org/scripts/show/22891"&gt;this script&lt;/a&gt;, created by Tim Harper, on userscripts.org within your Campfire Fluid.app instance.&lt;/p&gt;


	&lt;p&gt;Under the Userscripts menu, you&amp;#8217;ll see: Browse Userscripts.org.&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/8e99/userscripts"&gt;&lt;img src="http://img.skitch.com/20080305-1dqq1b6cfrc4rda7tdxrsga73g.preview.jpg" alt="Userscripts" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080"&gt;Uploaded with &lt;a href="http://plasq.com/"&gt;plasq&lt;/a&gt;&amp;#8217;s &lt;a href="http://skitch.com"&gt;Skitch&lt;/a&gt;!&lt;/span&gt;&lt;/div&gt;

	&lt;p&gt;Find your way to the script (search for: &amp;#8220;Campfire Growl&amp;#8221;) to find and install the script.&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/8jyg/growl-notifications-with-messages-for-campfire-and-fluid-userscripts.org"&gt;&lt;img src="http://img.skitch.com/20080305-nnq98j3xpx7pa8fb71ba7yfyg1.preview.jpg" alt="Growl Notifications with messages for campfire and fluid 2013 Userscripts.org" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080"&gt;Uploaded with &lt;a href="http://plasq.com/"&gt;plasq&lt;/a&gt;&amp;#8217;s &lt;a href="http://skitch.com"&gt;Skitch&lt;/a&gt;!&lt;/span&gt;&lt;/div&gt;

	&lt;p&gt;Once it installs, you&amp;#8217;ll then need to activate it in the Fluid applications management interface. Within Campfire application, go to &lt;strong&gt;Userscripts &amp;gt; Manage Userscripts&lt;/strong&gt;.&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/8jym/manage-userscripts"&gt;&lt;img src="http://img.skitch.com/20080305-8nxmc4nsawpmpwms696gnq9fum.preview.jpg" alt="manage userscripts" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080"&gt;Uploaded with &lt;a href="http://plasq.com/"&gt;plasq&lt;/a&gt;&amp;#8217;s &lt;a href="http://skitch.com"&gt;Skitch&lt;/a&gt;!&lt;/span&gt;&lt;/div&gt;

	&lt;p&gt;Then activate it like so:&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/8jyw/activate-growl"&gt;&lt;img src="http://img.skitch.com/20080305-ptths7kx55wi29npf73b7dbc1g.preview.jpg" alt="activate growl" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: Lucida Grande, Trebuchet, sans-serif, Helvetica, Arial; font-size: 10px; color: #808080"&gt;Uploaded with &lt;a href="http://plasq.com/"&gt;plasq&lt;/a&gt;&amp;#8217;s &lt;a href="http://skitch.com"&gt;Skitch&lt;/a&gt;!&lt;/span&gt;&lt;/div&gt;

	&lt;p&gt;..and that&amp;#8217;s it! When you&amp;#8217;re not focused on Campfire&amp;#8230; you should see Growl notifications when other people are talking in the active room.&lt;/p&gt;
</description>
      <pubDate>Wed, 05 Mar 2008 16:24:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:c4a0fc62-b4ab-420b-ad01-575608f46a21</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2008/03/05/campfire-messages-in-growl</link>
      <category>growl</category>
      <category>campfire</category>
      <category>osx</category>
      <category>notifications</category>
      <category>team</category>
      <category>communication</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Installing Ruby on Rails and PostgreSQL on OS X, Third Edition</title>
      <description>&lt;p&gt;Over the past few years, I&amp;#8217;ve helped you walk through the process of getting Ruby on Rails up and running on Mac &lt;span class="caps"&gt;OS X&lt;/span&gt;. The last version has been getting a lot of comments related to issues with the new Apple Leopard, so I&amp;#8217;m going this post will expand on previous installation guides with what&amp;#8217;s working for me as of January 2008.&lt;/p&gt;


	&lt;p&gt;The following guide is how our development team at &lt;a href="http://planetargon.com"&gt;Planet Argon&lt;/a&gt; prefers to setup our development workstations&lt;/p&gt;


	&lt;p&gt;During this installation, we&amp;#8217;ll have what we feel is the optimal development stack for building &lt;a href="http://rubyonrails.org"&gt;Ruby on Rails&lt;/a&gt; applications with our favorite database server, &lt;a href="http://postgresql.org"&gt;PostgreSQL&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Ready? Let&amp;#8217;s get started&amp;#8230;&lt;/p&gt;
&lt;h2&gt;Phase One&lt;/h2&gt;


	&lt;p&gt;During this initial phase, we&amp;#8217;re going to install the underlying dependencies that we&amp;#8217;ll be building off of.&lt;/p&gt;


	&lt;h3&gt;XCode 3.0&lt;/h3&gt;


	&lt;p&gt;The first thing that you&amp;#8217;ll need to install to get far with this process is XCode tools, which is distributed by Apple. You can find this on the &lt;span class="caps"&gt;DVD&lt;/span&gt; that your Leopard installer is on. You can also download the latest version from Apple&amp;#8217;s developer site.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://developer.apple.com/tools/download/"&gt;http://developer.apple.com/tools/download/&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The current version (3.0) is 1.1 GB.. so the download time will vary depending on your connection speed. I would encourage you to drink some tea and/or &lt;a href="http://www.amazon.com/gp/product/0684868768?ie=UTF8&amp;#38;tag=robonrai-20&amp;#38;linkCode=as2&amp;#38;camp=1789&amp;#38;creative=9325&amp;#38;creativeASIN=0684868768"&gt;read a book&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=robonrai-20&amp;#38;l=as2&amp;#38;o=1&amp;#38;a=0684868768" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;&lt;/p&gt;


	&lt;p&gt;Once you finish the installation, you can move forward. The rest of these installation &lt;strong&gt;will not work&lt;/strong&gt; until XCode is installed. :-)&lt;/p&gt;


	&lt;h3&gt;MacPorts&lt;/h3&gt;


	&lt;p&gt;In this next step, we&amp;#8217;ll install &lt;a href="http://www.macports.org/"&gt;MacPorts&lt;/a&gt; (formerly known as DarwinPorts). The MacPorts web site describes itself as, &lt;em&gt;&amp;#8220;an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, &lt;span class="caps"&gt;X11&lt;/span&gt; or Aqua based open-source software on the Mac &lt;span class="caps"&gt;OS X&lt;/span&gt; operating system.&amp;#8221;&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://img.skitch.com/20080122-jxqkyy8hc8ug7qxy4jt6qeg3d1.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;This tool is about to become one of the most important tools on your operating system as it&amp;#8217;ll be used time and time again to maintain your libraries and many of the Unix tools that you&amp;#8217;ll be using. If you’re from the Linux or &lt;span class="caps"&gt;BSD&lt;/span&gt; world, you are likely familiar with similar tools… such as: apt-get, port, and yum.&lt;/p&gt;


	&lt;p&gt;First, you&amp;#8217;ll want to download MacPorts and install the &amp;#8220;dmg&amp;#8221; disk file for Leopard at the following link.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://www.macports.org/install.php"&gt;http://www.macports.org/install.php&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Once downloaded, you&amp;#8217;ll want to run the installer and install it on your workstation.&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/fdqg/install-macports-1.6.0"&gt;&lt;img src="http://img.skitch.com/20080122-efm4gb9pbb79p4ujya1ceisn37.preview.jpg" alt="Install MacPorts-1.6.0" /&gt;&lt;/a&gt;&lt;/div&gt;

	&lt;p&gt;Work you way through the installer until successfully installed.&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/fdqe/install-macports-1.6.0"&gt;&lt;img src="http://img.skitch.com/20080122-rr9e1begkg73ixt11d697wpdfh.preview.jpg" alt="Install MacPorts-1.6.0" /&gt;&lt;/a&gt;&lt;/div&gt;

	&lt;p&gt;Once this finishes, you can open up your favorite terminal application and run the following to test that it installed properly.&lt;/p&gt;


	&lt;p&gt;In my case, I&amp;#8217;m now using Terminal.app.&lt;/p&gt;


	&lt;p&gt;Issue the command: &lt;code&gt;/opt/local/bin/port version&lt;/code&gt;&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/fdqm/opt-local-bin-port-version"&gt;&lt;img src="http://img.skitch.com/20080122-piqes1e66rgj1bui7eud9sisf7.preview.jpg" alt="_opt_local_bin_port version" /&gt;&lt;/a&gt;&lt;/div&gt;

	&lt;p&gt;If it responds with a version number like mine did in the screenshot above, we&amp;#8217;re moving along nicely.&lt;/p&gt;


	&lt;h3&gt;Environment Paths&lt;/h3&gt;


	&lt;p&gt;When we install MacPorts, the command to install/update ports installed to &lt;code&gt;/opt/local/bin&lt;/code&gt;. We had to provide the entire path as this isn&amp;#8217;t currently showing up in the default &lt;code&gt;$PATH&lt;/code&gt; on Leopard. Let&amp;#8217;s quickly remedy this by modifying the file &lt;code&gt;/etc/profile&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;If you have Textmate installed, you can run the following from your terminal: &lt;code&gt;mate /etc/profile&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Add the following line to the bottom of &lt;code&gt;/etc/profile&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;export PATH=/opt/local/bin:/opt/local/sbin:$PATH&lt;/code&gt;&lt;/pre&gt;

&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/fdxb/profile"&gt;&lt;img src="http://img.skitch.com/20080122-mqk8awqpbeebmdq7p7r1gyixsy.preview.jpg" alt="profile" /&gt;&lt;/a&gt;&lt;/div&gt;

	&lt;p&gt;You can use your favorite editor to update this file. Once you save it, you&amp;#8217;ll want to restart your terminal application (or open a new tab) to create a new session. When your new terminal opens, run the following to verify that &lt;code&gt;port&lt;/code&gt; is showing up in your &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;which port&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;You should see &lt;code&gt;/opt/local/bin/port&lt;/code&gt; show up as the result of this command.&lt;/p&gt;


&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/fdx8/which-port"&gt;&lt;img src="http://img.skitch.com/20080122-d4hte4cm5gn67a4cum26gbibut.preview.jpg" alt="which port" /&gt;&lt;/a&gt;&lt;/div&gt;

	&lt;p&gt;Great, let&amp;#8217;s continue to move forward.&lt;/p&gt;


	&lt;h3&gt;Hiding Apple&amp;#8217;s Ruby, Gems, and Rails&lt;/h3&gt;


	&lt;p&gt;Before we install Ruby from MacPorts, we&amp;#8217;ll go ahead and hide Apple&amp;#8217;s Ruby installations.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
    :~ robbyrussell$ sudo su -
    Password:
    :~ root# mv /usr/bin/ruby /usr/bin/ruby.orig
    :~ root# mv /usr/bin/gem /usr/bin/gem.orig
    :~ root# mv /usr/bin/rails /usr/bin/rails.orig
    :~ root# logout    
&lt;/code&gt;&lt;/pre&gt;

&lt;div class="thumbnail"&gt;&lt;a href="http://skitch.com/robbyrussell/fdxe/hiding-apples-ruby"&gt;&lt;img src="http://img.skitch.com/20080122-rgmsuy746h73b1bc93j4nyi5ar.preview.jpg" alt="hiding apples ruby" /&gt;&lt;/a&gt;&lt;/div&gt;

	&lt;p&gt;If you ever decide to remove MacPorts, you can just rename &lt;code&gt;ruby.orig&lt;/code&gt; back to &lt;code&gt;ruby&lt;/code&gt; and you&amp;#8217;re back where you started&amp;#8230; and the same for the others listed.&lt;/p&gt;


	&lt;h2&gt;Phase Two&lt;/h2&gt;


	&lt;p&gt;During this next phase, we&amp;#8217;re going to install Ruby and Ruby on Rails.&lt;/p&gt;


	&lt;h3&gt;Installing Ruby via MacPorts&lt;/h3&gt;


	&lt;p&gt;Now that we have MacPorts up and running, we&amp;#8217;re going to use it for the first time. We&amp;#8217;ll start by using it to install Ruby and the Rubygems package.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ sudo port install ruby rb-rubygems&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Okay, this will take a little while. I&amp;#8217;d suggest that you step out to get some fresh air.&lt;/p&gt;


	&lt;p&gt;How was it outside? What&amp;#8217;s the weather like there today? It&amp;#8217;s currently 2:30am &lt;span class="caps"&gt;PST&lt;/span&gt; so it&amp;#8217;s dark and an 28F outside so I didn&amp;#8217;t stay outside very long.&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re still waiting for it to install, perhaps you could watch the following video. I might encourage you to check out more of &lt;a href="http://en.wikipedia.org/wiki/Jam_%28TV_series%29"&gt;Jam&lt;/a&gt;, which was recommended a few years ago to me by &lt;a href="http://interblah.net/"&gt;James Adam&lt;/a&gt; at &lt;a href="http://www.canadaonrails.org/"&gt;Canada on Rails&lt;/a&gt;.&lt;/p&gt;


&lt;object width="425" height="355"&gt;&lt;param name="movie" value="http://www.youtube.com/v/sLD0SNCFtyA&amp;#38;rel=1"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/sLD0SNCFtyA&amp;#38;rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;

	&lt;p&gt;Be warned&amp;#8230; it&amp;#8217;s a strange show, but I find strange things like this funny. :-)&lt;/p&gt;


	&lt;p&gt;If you prefer something a bit more lighthearted&amp;#8230;&lt;/p&gt;


&lt;object width="425" height="355"&gt;&lt;param name="movie" value="http://www.youtube.com/v/SO5WoLnOOlU&amp;#38;rel=1"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/SO5WoLnOOlU&amp;#38;rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;

	&lt;p&gt;Okay&amp;#8230; when Ruby finishes installing, you&amp;#8217;ll want to test that you can run it.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ ruby -v&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great, let&amp;#8217;s move forward!&lt;/p&gt;


	&lt;h3&gt;Installing Ruby on Rails via RubyGems&lt;/h3&gt;


	&lt;p&gt;We&amp;#8217;re now going to install the libraries that make up Ruby on Rails via RubyGems.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ sudo gem install --include-dependencies rails&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This will install the following gems.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;rails-2.0.2&lt;/li&gt;
		&lt;li&gt;rake-0.8.1&lt;/li&gt;
		&lt;li&gt;activesupport-2.0.2&lt;/li&gt;
		&lt;li&gt;activerecord-2.0.2&lt;/li&gt;
		&lt;li&gt;actionpack-2.0.2&lt;/li&gt;
		&lt;li&gt;actionmailer-2.0.2&lt;/li&gt;
		&lt;li&gt;activeresource-2.0.2&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Excellent, let&amp;#8217;s move forward&amp;#8230;&lt;/p&gt;


	&lt;p&gt;If you haven&amp;#8217;t already purchased it, I recommend that you take a look at &lt;a href="http://www.amazon.com/gp/product/0321445619?ie=UTF8&amp;#38;tag=robonrai-20&amp;#38;linkCode=as2&amp;#38;camp=1789&amp;#38;creative=9325&amp;#38;creativeASIN=0321445619"&gt;The Rails Way (Addison-Wesley Professional Ruby Series)&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=robonrai-20&amp;#38;l=as2&amp;#38;o=1&amp;#38;a=0321445619" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; by Obie Fernandez.&lt;/p&gt;


	&lt;h3&gt;Installing Mongrel via RubyGems&lt;/h3&gt;


	&lt;p&gt;Let&amp;#8217;s now install Mongrel, which is an excellent Ruby-based web server for Ruby on Rails applications. We use it in development and production at &lt;a href="http://planetargon.com"&gt;Planet Argon&lt;/a&gt; and it&amp;#8217;s also what we recommend to our &lt;a href="http://planetargon.com/hosting.html"&gt;hosting customers&lt;/a&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ sudo gem install --include-dependencies mongrel mongrel_cluster&lt;/code&gt;&lt;/pre&gt;

	&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;Note:&lt;/strong&gt; Be sure to select the proper platform for mongrel. (hint: &lt;span class="caps"&gt;OS X&lt;/span&gt; is &lt;span class="caps"&gt;NOT&lt;/span&gt; mswin32)&lt;/li&gt;
	&lt;/ul&gt;


My terminal output:
&lt;pre&gt;&lt;code&gt;
Select which gem to install for your platform (i686-darwin9.1.0)
 1. mongrel 1.1.3 (java)
 2. mongrel 1.1.3 (i386-mswin32)
 3. mongrel 1.1.3 (ruby)
 4. mongrel 1.1.2 (ruby)
 5. mongrel 1.1.2 (mswin32)
 6. mongrel 1.1.2 (java)
 7. Skip this gem
 8. Cancel installation
&amp;gt; 3
Select which gem to install for your platform (i686-darwin9.1.0)
 1. fastthread 1.0.1 (mswin32)
 2. fastthread 1.0.1 (ruby)
 3. Skip this gem
 4. Cancel installation
&amp;gt; 2
Building native extensions.  This could take a while...
Building native extensions.  This could take a while...
Successfully installed mongrel-1.1.3
Successfully installed gem_plugin-0.2.3
Successfully installed daemons-1.0.9
Successfully installed fastthread-1.0.1
Successfully installed cgi_multipart_eof_fix-2.5.0
Installing ri documentation for mongrel-1.1.3...
Installing ri documentation for gem_plugin-0.2.3...
Installing ri documentation for daemons-1.0.9...
Installing ri documentation for fastthread-1.0.1...

No definition for dummy_dump

No definition for dummy_dump

No definition for rb_queue_marshal_load

No definition for rb_queue_marshal_dump
Installing ri documentation for cgi_multipart_eof_fix-2.5.0...
Installing RDoc documentation for mongrel-1.1.3...
Installing RDoc documentation for gem_plugin-0.2.3...
Installing RDoc documentation for daemons-1.0.9...
Installing RDoc documentation for fastthread-1.0.1...

No definition for dummy_dump

No definition for dummy_dump

No definition for rb_queue_marshal_load

No definition for rb_queue_marshal_dump
Installing RDoc documentation for cgi_multipart_eof_fix-2.5.0...
Successfully installed mongrel_cluster-1.0.5
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great, you have almost all of the essentials.. except a database.&lt;/p&gt;


	&lt;h2&gt;Phase Three&lt;/h2&gt;


	&lt;p&gt;In this phase, we&amp;#8217;re going to get our database server, PostgreSQL, installed and the libraries that Ruby needs to communicate with it.&lt;/p&gt;


	&lt;h3&gt;Installing PosgreSQL with MacPorts&lt;/h3&gt;


	&lt;p&gt;At &lt;a href="http://planetargon.com"&gt;Planet Argon&lt;/a&gt;, we design and develop our applications on top of &lt;a href="http://postgresql.org"&gt;PostgreSQL&lt;/a&gt;. I’ve been advocating the adoption of this awesome open source database in the Rails community for quite some time now.&lt;/p&gt;


	&lt;p&gt;The current version available of PostgreSQL via MacPorts is 8.3, which is what we&amp;#8217;ll now install with the &lt;code&gt;port&lt;/code&gt; command.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;$ sudo port install postgresql83 postgresql83-server&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;This will download and install the necessary libraries to run PostgreSQL server and the client utilities.&lt;/p&gt;


	&lt;h3&gt;Configuring PostgreSQL&lt;/h3&gt;


	&lt;p&gt;When PostgreSQL is finished installing, it&amp;#8217;ll tell you to run the following commands to create a new database instance.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb
 sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb
 sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'
&lt;/code&gt;&lt;/pre&gt;

	&lt;h4&gt;Adding PostgreSQL to launchd&lt;/h4&gt;


	&lt;p&gt;If you&amp;#8217;d like to have PostgreSQL automatically startup after a system restart, you can load it into launchd, which comes with &lt;span class="caps"&gt;OS X&lt;/span&gt;. By running the following command, PostgreSQL will startup automatically on the next system restart.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist&lt;/code&gt;&lt;/pre&gt;

	&lt;h4&gt;Adding PostgreSQL to your $PATH&lt;/h4&gt;


	&lt;p&gt;For some reason, the MacPort for PostgreSQL doesn&amp;#8217;t get the programs in your path automatically, so we&amp;#8217;ll it now.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;mate /etc/profile&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;Modify the &lt;code&gt;PATH&lt;/code&gt; that we changed earlier to include /opt/local/lib/postgresql83/bin@.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql83/bin:$PATH&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Save the file and then open a new terminal. To test this, you should get the following output when you run which &lt;code&gt;psql&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  $ which psql
  /opt/local/lib/postgresql83/bin/psql    
&lt;/code&gt;&lt;/pre&gt;

	&lt;h4&gt;Creating a new PostgreSQL user&lt;/h4&gt;


	&lt;p&gt;When I’m working on Rails applications in my development environment, I really don’t want to have to specify a username and password in every &lt;code&gt;config/database.yml&lt;/code&gt; file for each of our ongoing client projects. When PostgreSQL was installed, it created a superuser named &lt;strong&gt;postgres&lt;/strong&gt;, which is great, but I’d like one that matches my system username, so that I’m not prompted at all for a username or password to connect to PostgreSQL.&lt;/p&gt;


	&lt;p&gt;To do this, we’ll use the &lt;code&gt;createuser&lt;/code&gt; command, which comes with PostgreSQL. As you can see, I’m creating a new user with &lt;code&gt;superuser&lt;/code&gt; privileges (and will hopefully be the last time I have to do a &lt;code&gt;-U postgres&lt;/code&gt;).&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  $ createuser --superuser robbyrussell -U postgres
  CREATE ROLE    
&lt;/code&gt;&lt;/pre&gt;

Let’s take a quick moment to test this out.
&lt;pre&gt;&lt;code&gt;
  # create a new database
  $ createdb my_test_db
  CREATE DATABASE

  # drop the database
  $ dropdb my_test_db
  DROP DATABASE
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great, everything looks good here.&lt;/p&gt;


	&lt;p&gt;We now have a running installation of PostgreSQL with a new user account. All we need to do now is install the appropriate RubyGem to allow our Ruby applications to connect to it.&lt;/p&gt;


	&lt;h4&gt;Installing PostgreSQL Libraries for Ruby&lt;/h4&gt;


	&lt;p&gt;You can install postgres gem by running the following command.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$  sudo gem install --include-dependencies postgres&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great. We’ve now built a professional development environment for working with Ruby on Rails. Can you &lt;em&gt;feel&lt;/em&gt; the excitement? :-)&lt;/p&gt;


	&lt;h2&gt;Closing Thoughts&lt;/h2&gt;


	&lt;p&gt;Like the previous versions, I hope that a few people find this useful. I didn&amp;#8217;t have to make a lot of changes from the second edition, but there were enough to warrant a new post. I&amp;#8217;ve been setting up my workstation like this for about three years now and I&amp;#8217;m looking forward to seeing how a fresh install on Leopard works out for me.&lt;/p&gt;


	&lt;p&gt;If you have any problems, feel free to ask a question in the comments below.&lt;/p&gt;</description>
      <pubDate>Tue, 22 Jan 2008 11:55:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:73dcd126-1333-417e-9203-aaefb22a65b1</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2008/01/22/installing-ruby-on-rails-and-postgresql-on-os-x-third-edition</link>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>PostgreSQL</category>
      <category>PLANET ARGON</category>
      <category>rubyonrails</category>
      <category>rails</category>
      <category>postgresql</category>
      <category>xcode</category>
      <category>apple</category>
      <category>osx</category>
      <category>macports</category>
      <category>ruby</category>
      <category>rubygems</category>
      <category>irb</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Installing Ruby on Rails and PostgreSQL on OS X, Second Edition</title>
      <description>&lt;p&gt;It&amp;#8217;s been just over a year since I posted the article, &lt;a href="http://www.robbyonrails.com/articles/2006/05/29/install-ruby-rails-and-postgresql-on-osx"&gt;Install Ruby, Rails, and PostgreSQL on &lt;span class="caps"&gt;OSX&lt;/span&gt;&lt;/a&gt; and it still gets quite a bit of traffic. Unfortunately, there have been a few changes in the install process that have caught people.&lt;/p&gt;


	&lt;p&gt;Today, I am leaving my PowerBook G4. It&amp;#8217;s being replaced with a MacBook because the logic board is on the fritz. So, guess what that means? I get to install Ruby, Ruby on Rails, PostgreSQL on &lt;span class="caps"&gt;OS X&lt;/span&gt; again! I figured that I would post a revised version of my previous article for those who may go through this same process in the near future.&lt;/p&gt;


&lt;div class="warning"&gt;
&lt;strong&gt;&lt;span class="caps"&gt;&lt;span class="caps"&gt;WARNING&lt;/span&gt;&lt;/span&gt;:&lt;/strong&gt; This post contains some outdated instructions. Please read &lt;a href="http://www.robbyonrails.com/articles/2008/01/22/installing-ruby-on-rails-and-postgresql-on-os-x-third-edition"&gt; Installing Ruby on Rails and PostgreSQL on &lt;span class="caps"&gt;&lt;span class="caps"&gt;OS X&lt;/span&gt;&lt;/span&gt;, Third Edition&lt;/a&gt;, which is focused on Installing Ruby on Rails on Leopard.
&lt;/div&gt;
&lt;h2&gt;Step Zero: Install iTerm (optional)&lt;/h2&gt;


	&lt;p&gt;You&amp;#8217;ll spend a lot of time in your terminal as a Rails developer. I&amp;#8217;m not a big fan of Terminal.app as it lacks tabbed windows&lt;sup&gt;&lt;a href="#fn1"&gt;1&lt;/a&gt;&lt;/sup&gt; and you&amp;#8217;ll often find me with around ten tabs open. I&amp;#8217;ve been using &lt;a href="http://iterm.sourceforge.net/"&gt;iTerm&lt;/a&gt; for a few years and it&amp;#8217;s definitely improved in the past year and doesn&amp;#8217;t seem to crash nearly as often as it used to.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://iterm.sourceforge.net/download.shtml"&gt;Download the latest iTerm release&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Once installed, I always change the default color scheme as I prefer the white on black schema. The menus in iTerm are lacking some thoughtful interaction design, but I&amp;#8217;ve figured out the right way to do it (after a long time of stumbling on it by accident). In iTerm, you&amp;#8217;ll want to &lt;strong&gt;edit&lt;/strong&gt; the Default bookmark, which you can access by going to Manage Bookmarks under the Bookmarks Menu.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://www.robbyonrails.com/files/ror_osx_iterm_bookmark.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Set the &lt;strong&gt;Display&lt;/strong&gt; value to &lt;strong&gt;classic iTerm&lt;/strong&gt; and you&amp;#8217;re golden.&lt;/p&gt;


	&lt;p&gt;Now&amp;#8230; let&amp;#8217;s get to business&amp;#8230;&lt;/p&gt;


	&lt;h2&gt;Step 1: Install Xcode Tools&lt;/h2&gt;


	&lt;p&gt;Without installing Xcode tools from Apple, we&amp;#8217;re not going to get very far. First, you&amp;#8217;ll need to grab a copy of Xcode, which you can download on Apple&amp;#8217;s Developer Connection site. It&amp;#8217;s almost a 1GB download, so you&amp;#8217;ll want to start your download and use your multi-tasking skills and &lt;a href="http://drinkviso.com/"&gt;grab a Viso&lt;/a&gt;, read some &lt;a href="http://www.planetrubyonrails.org"&gt;blog&lt;/a&gt; &lt;a href="http://therailsway.com/"&gt;posts&lt;/a&gt;.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://developer.apple.com/tools/download/"&gt;Download Xcode&lt;/a&gt; (dmg)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;I&amp;#8217;m going to make the assumption here that you know how to install a dmg on osx. Once this is installed, you can move on to the next step!&lt;/p&gt;


	&lt;h2&gt;Step 2: All Your MacPorts are Belong to Us&lt;/h2&gt;


	&lt;p&gt;&lt;a href="http://www.macports.org/"&gt;MacPorts&lt;/a&gt; (formerly known as DarwinPorts) is a package management system for &lt;span class="caps"&gt;OS X&lt;/span&gt;. This is what we&amp;#8217;ll use to install most of the necessary programs to develop and run your Ruby on Rails applications. If you&amp;#8217;re from the Linux or &lt;span class="caps"&gt;BSD&lt;/span&gt; world, you are likely familiar with similar tools&amp;#8230; such as: &lt;code&gt;apt-get&lt;/code&gt;, &lt;code&gt;port&lt;/code&gt;, and &lt;code&gt;yum&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;You&amp;#8217;ll want to download MacPorts and install the dmg file.&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://www.robbyonrails.com/files/ror_osx_macports.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Now that this is installed, we should test it.&lt;/p&gt;


	&lt;p&gt;With a new terminal, run the following:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ port version
Version: 1.442
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Success! Let&amp;#8217;s get going&amp;#8230;&lt;/p&gt;


	&lt;h2&gt;Step 3: Installing the Ruby on Rails development stack&lt;/h2&gt;


	&lt;p&gt;We&amp;#8217;re going to go through a series of small steps, which may take some time depending on how fast your internet connection and computer is.&lt;/p&gt;


	&lt;h3&gt;Install Ruby and RubyGems&lt;/h3&gt;


	&lt;p&gt;In order to install Ruby, we&amp;#8217;re going to use MacPorts with the &lt;code&gt;port&lt;/code&gt; command, which is now available for installing various packages on our &lt;span class="caps"&gt;OS X&lt;/span&gt; machines.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ sudo port install ruby rb-rubygems&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;It&amp;#8217;ll probably take a while to download and install Ruby and all of it&amp;#8217;s known dependencies. In the meantime, check out &lt;a href="http://lolcode.com/"&gt;some funny code&lt;/a&gt;. &lt;span class="caps"&gt;KTHXBYE&lt;/span&gt;!&lt;/p&gt;


	&lt;p&gt;Still waiting for it to install, perhaps you could do something like&amp;#8230; begin writing a comment on this post, writing your own blog post, &lt;a href="http://www.youtube.com/watch?v=sLD0SNCFtyA"&gt;watch a funny video&lt;/a&gt;, or &lt;a href="http://workingwithrails.com/recommendation/new/person/5408-robby-russell"&gt;recommend me&lt;/a&gt;. I walked to &lt;a href="http://www.backspace.bz/"&gt;Backspace&lt;/a&gt; with Gary to get an Americano&amp;#8230; and it&amp;#8217;s still not done. :-p&lt;/p&gt;


	&lt;p&gt;(minutes/hours/weeks later)&lt;/p&gt;


	&lt;p&gt;Okay&amp;#8230; I trust that it finished installing Ruby and RubyGems without any hiccups. Let&amp;#8217;s test them from our terminal to make sure.&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s check the version&amp;#8230;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Now, let&amp;#8217;s make sure that Ruby is working properly&amp;#8230;&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
$ irb
irb(main):001:0&amp;gt; x = 1     
=&amp;gt; 1
irb(main):002:0&amp;gt; puts "wee!!!" if x == 1
wee!!!
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great, we&amp;#8217;re on a roll. Let&amp;#8217;s get the rest of the stack installed.&lt;/p&gt;


	&lt;h3&gt;Install Ruby on Rails&lt;/h3&gt;


	&lt;p&gt;We&amp;#8217;re going to install Ruby on Rails with the &lt;code&gt;gem&lt;/code&gt; command that installing RubyGems provided.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ sudo gem install -y rails
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This command should produce an output similar to the following.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
Successfully installed rails-1.2.3
Successfully installed rake-0.7.3
Successfully installed activesupport-1.4.2
Successfully installed activerecord-1.15.3
Successfully installed actionpack-1.13.3
Successfully installed actionmailer-1.3.3
Successfully installed actionwebservice-1.2.3
Installing ri documentation for rake-0.7.3...
Installing ri documentation for activesupport-1.4.2...
Installing ri documentation for activerecord-1.15.3...
Installing ri documentation for actionpack-1.13.3...
Installing ri documentation for actionmailer-1.3.3...
Installing ri documentation for actionwebservice-1.2.3...
Installing RDoc documentation for rake-0.7.3...
Installing RDoc documentation for activesupport-1.4.2...
Installing RDoc documentation for activerecord-1.15.3...
Installing RDoc documentation for actionpack-1.13.3...
Installing RDoc documentation for actionmailer-1.3.3...
Installing RDoc documentation for actionwebservice-1.2.3...    
&lt;/code&gt;&lt;/pre&gt;

	&lt;h3&gt;Install Rails-friendly gems&lt;/h3&gt;


	&lt;p&gt;&lt;strong&gt;Mongrel&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;If you&amp;#8217;re developing with Rails, it&amp;#8217;s highly recommended that you use install and use &lt;a href="http://mongrel.rubyforge.org"&gt;Mongrel&lt;/a&gt; for your development and production environments. The following command will install the mongrel and mongrel_cluster gems (including their dependencies).&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ sudo gem install -y mongrel mongrel_cluster&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;&lt;small&gt;* Note: Be sure to select the proper platform for mongrel. (hint: &lt;span class="caps"&gt;OS X&lt;/span&gt; is &lt;span class="caps"&gt;NOT&lt;/span&gt; mswin32)&lt;/small&gt;&lt;/p&gt;


	&lt;p&gt;My terminal output:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ sudo gem install -y mongrel mongrel_cluster
Password:
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i686-darwin8.9.1)
 1. mongrel 1.0.1 (mswin32)
 2. mongrel 1.0.1 (ruby)
 3. mongrel 1.0 (mswin32)
 4. mongrel 1.0 (ruby)
 5. Skip this gem
 6. Cancel installation
&amp;gt; 2
Select which gem to install for your platform (i686-darwin8.9.1)
 1. fastthread 1.0 (ruby)
 2. fastthread 1.0 (mswin32)
 3. fastthread 0.6.4.1 (mswin32)
 4. fastthread 0.6.4.1 (ruby)
 5. Skip this gem
 6. Cancel installation
&amp;gt; 1
Building native extensions.  This could take a while...
Building native extensions.  This could take a while...
Successfully installed mongrel-1.0.1
Successfully installed daemons-1.0.6
Successfully installed fastthread-1.0
Successfully installed gem_plugin-0.2.2
Successfully installed cgi_multipart_eof_fix-2.1
Installing ri documentation for mongrel-1.0.1...
Installing ri documentation for daemons-1.0.6...
Installing ri documentation for gem_plugin-0.2.2...
Installing ri documentation for cgi_multipart_eof_fix-2.1...
Installing RDoc documentation for mongrel-1.0.1...
Installing RDoc documentation for daemons-1.0.6...
Installing RDoc documentation for gem_plugin-0.2.2...
Installing RDoc documentation for cgi_multipart_eof_fix-2.1...
Successfully installed mongrel_cluster-0.2.1    
&lt;/code&gt;&lt;/pre&gt;

	&lt;h2&gt;Step 4: Installing the World&amp;#8217;s Most Advanced Database Server&amp;#8230; PostgreSQL!&lt;/h2&gt;


	&lt;p&gt;At &lt;a href="http://planetargon.com"&gt;&lt;span class="caps"&gt;PLANET ARGON&lt;/span&gt;&lt;/a&gt;, we develop our applications on top of &lt;a href="http://postgresql.or"&gt;PostgreSQL&lt;/a&gt;. I&amp;#8217;ve long been advocating the adoption of this &lt;em&gt;awesome&lt;/em&gt; open source database in the Rails community. Just over a year ago, &lt;a href="http://jvoorhis.com"&gt;Jeremy Voorhis&lt;/a&gt; (PLANET &lt;span class="caps"&gt;ARGON&lt;/span&gt; alumnus) and I were &lt;a href="http://odeo.com/audio/1069086/view"&gt;interviewed on the Ruby on Rails podcast&lt;/a&gt; and had the opportunity to discuss our preference of PostgreSQL over the alternatives (mysql, sqlite, firebird, etc.).&lt;/p&gt;


	&lt;p&gt;We&amp;#8217;re going to install &lt;a href="http://www.postgresql.org/docs/8.2/static/release-8-2.html"&gt;PostgreSQL 8.2&lt;/a&gt; from MacPorts by running the following command.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ sudo port install postgresql82 postgresql82-server&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;While this is installing, you might take a moment to check out &lt;a href="http://whytheluckystiff.net/comics/differentSpaceShuttles.html"&gt;some space shuttles&lt;/a&gt;.&lt;/p&gt;


	&lt;h3&gt;Setting up PostgreSQL&lt;/h3&gt;


	&lt;p&gt;You may have noticed the output of the previous port installation of PostgreSQL 8.2, suggested that you do the following. Let&amp;#8217;s do that now&amp;#8230;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ sudo mkdir -p /opt/local/var/db/postgresql82/defaultdb
$ sudo chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb
$ sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb'    
&lt;/code&gt;&lt;/pre&gt;

	&lt;h4&gt;Have PostgreSQL start automatically on system start-ups&lt;/h4&gt;


	&lt;p&gt;Unless you&amp;#8217;re concerned about extra applications running in the background, I&amp;#8217;d encourage you to add PostgreSQL to launchd, which will start it automatically after system reboots.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql82-server.plist&lt;/code&gt;&lt;/pre&gt;

	&lt;h4&gt;Adding PostgreSQL commands to your $PATH&lt;/h4&gt;


	&lt;p&gt;For some reason, MacPorts doesn&amp;#8217;t add the PostgreSQL programs to the default bash &lt;span class="caps"&gt;PATH&lt;/span&gt;, which means that you can&amp;#8217;t run &lt;code&gt;psql&lt;/code&gt;, &lt;code&gt;pg_dump&lt;/code&gt;, or &lt;code&gt;createdb&lt;/code&gt;/&lt;code&gt;dropdb&lt;/code&gt; without specifying the full path to where they were installed. What we&amp;#8217;ll do is add them to our default terminal profile.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;sudo vi /etc/profile&lt;/code&gt;&lt;/pre&gt; (you can use &lt;code&gt;mate&lt;/code&gt;, &lt;code&gt;emacs&lt;/code&gt;, &lt;code&gt;joe&lt;/code&gt; or any other preferred editor to do this)

	&lt;p&gt;This file gets loaded every time a new terminal session is started.&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s add &lt;code&gt;/opt/local/lib/postgresql82/bin&lt;/code&gt; to the end of the value for &lt;span class="caps"&gt;PATH&lt;/span&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/opt/local/lib/postgresql82/bin"    
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Save the file and then open a new terminal. To test this, you should get the following output when you run &lt;code&gt;which psql&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ which psql
/opt/local/lib/postgresql82/bin/psql
&lt;/code&gt;&lt;/pre&gt;

	&lt;h4&gt;Creating a new PostgreSQL user&lt;/h4&gt;


	&lt;p&gt;When I&amp;#8217;m working on Rails applications in my development environment, I really don&amp;#8217;t want to have to specify a username and password in every &lt;code&gt;config/database.yml&lt;/code&gt; file for each of our ongoing client projects. When PostgreSQL was installed, it created a superuser named &lt;code&gt;postgres&lt;/code&gt;, which is great, but I&amp;#8217;d like one that matches my system username, so that I&amp;#8217;m not prompted at all for a username or password to connect to PostgreSQL.&lt;/p&gt;


	&lt;p&gt;To do this, we&amp;#8217;ll use the &lt;code&gt;createuser&lt;/code&gt; command, which comes with PostgreSQL. As you can see, I&amp;#8217;m creating a new user with superuser privileges (and will hopefully be the last time I have to do a -U postgres).&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ createuser --superuser robbyrussell -U postgres
CREATE ROLE
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Let&amp;#8217;s take a quick moment to test this out.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
# create a new database
$ createdb my_test_db
CREATE DATABASE

# drop the database
$ dropdb my_test_db
DROP DATABASE
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great, everything looks good here.&lt;/p&gt;


	&lt;p&gt;We now have a running installation of PostgreSQL with a new user account. All we need to do now is install the appropriate RubyGem to allow our Ruby applications to connect to it.&lt;/p&gt;


	&lt;h3&gt;Installing the Ruby Postgres gem&lt;/h3&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt;&lt;/strong&gt;: Hydro posted a commented, which lead me to the ruby-postgres gem.&lt;/p&gt;


	&lt;p&gt;You can install ruby-postgres gem by running the following command.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ sudo gem install -y ruby-postgres
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Let&amp;#8217;s take a moment to test that this installed properly.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ irb
irb(main):001:0&amp;gt; require 'rubygems'
=&amp;gt; true
irb(main):002:0&amp;gt; require 'postgres'
=&amp;gt; true
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;If this returns true, than we should be good to go. We&amp;#8217;ve now built a professional development environment for working with Ruby on Rails. &lt;strong&gt;Doesn&amp;#8217;t that feel great?&lt;/strong&gt;&lt;/p&gt;


	&lt;h2&gt;Test your install&lt;/h2&gt;


	&lt;p&gt;You can look back at &lt;a href="http://www.robbyonrails.com/articles/2006/05/29/install-ruby-rails-and-postgresql-on-osx"&gt;my older post&lt;/a&gt; to walk through the process of testing out your setup with a new Rails application.&lt;/p&gt;


	&lt;h2&gt;Closing thoughts&lt;/h2&gt;


	&lt;p&gt;I hope that this post has been useful for you. It took me a few hours to walk through this process and it&amp;#8217;s how all of our designers and developers at &lt;a href="http://planetargon.com"&gt;&lt;span class="caps"&gt;PLANET ARGON&lt;/span&gt;&lt;/a&gt; installs and configures their development environment.&lt;/p&gt;


	&lt;p&gt;We also install the following programs on new machines.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://macromates.com/"&gt;TextMate&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Subversion: &lt;code&gt;sudo port install subversion&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;RSpec: &lt;code&gt;sudo gem install -y rspec&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;...amongst other gems that are needed on specific projects&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Until next time&amp;#8230; have fun!&lt;/p&gt;


	&lt;p id="fn1"&gt;&lt;sup&gt;1&lt;/sup&gt; Rumor: Mac &lt;span class="caps"&gt;OS X&lt;/span&gt; Leopard will give Terminal.app tabs! (&lt;a href="http://www.apple.com/macosx/leopard/technology/unix.html"&gt;see screenshot&lt;/a&gt;)&lt;/p&gt;</description>
      <pubDate>Tue, 19 Jun 2007 13:54:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:99f3a321-f222-4716-b70e-f62fcb7829c1</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2007/06/19/installing-ruby-on-rails-and-postgresql-on-os-x-second-edition</link>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>Programming</category>
      <category>PostgreSQL</category>
      <category>PLANET ARGON</category>
      <category>rails</category>
      <category>ruby</category>
      <category>postgresql</category>
      <category>subversion</category>
      <category>irb</category>
      <category>rubyonrails</category>
      <category>osx</category>
      <category>tutorial</category>
      <category>apple</category>
      <category>rubygems</category>
      <category>xcode</category>
      <category>macports</category>
      <category>macbook</category>
    </item>
    <item>
      <title>Sharing Custom TextMate Bundles with Subversion</title>
      <description>&lt;p&gt;Early last year, I began to start creating a bunch of snippets and such for &lt;a href="http://macromates.com"&gt;TextMate&lt;/a&gt;, all of which were lost several months ago due to &lt;a href="http://www.robbyonrails.com/articles/2006/08/11/isight-magnet-is-teh-suck"&gt;Hurricane iSight&lt;/a&gt;. I recently decided to start building some again, especially some that sped up my &lt;a href="http://rspec.rubyforge.org"&gt;RSpec&lt;/a&gt; writing. After creating a few, I wondered, &amp;#8220;would anybody else on my team want to help me write some?&amp;#8221; So, I thought that it was time to figure out how to share my bundle with others and allow them to add stuff to it&amp;#8230; which seems like a good job for Ms. Subversion.&lt;/p&gt;


	&lt;p&gt;I couldn&amp;#8217;t find a quick walk-through online and found myself in the &lt;code&gt;#textmate&lt;/code&gt; IRC channel getting proper instructions. (thank you &lt;a href="http://macromates.com/blog/"&gt;Allan&lt;/a&gt;!)&lt;/p&gt;


	&lt;h2&gt;Create Your Bundle&lt;/h2&gt;


	&lt;p&gt;In TextMate, you can open up the Bundle Editor and create a new bundle. Let&amp;#8217;s call our custom bundle, &lt;strong&gt;RSpec&lt;/strong&gt;. Go ahead and begin adding some snippets, commands, etc to your new custom bundle. Once you have something in your Bundle, you&amp;#8217;ll want to reload your bundles, by going to &lt;strong&gt;Bundles &amp;gt; Bundle Editor &amp;gt; Reload Bundles&lt;/strong&gt;. This will write your new bundle to disk to &lt;code&gt;~/Library/Application\ Support/TextMate/Bundles/&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
    $ ls -al ~/Library/Application\ Support/TextMate/Bundles/
    total 0
    drwxr-xr-x   5 robbyrus  robbyrus  170 Feb 11 21:10 .
    drwxr-xr-x   4 robbyrus  robbyrus  136 Feb 11 20:11 ..
    drwxr-xr-x   5 robbyrus  robbyrus  170 Jan 12 16:58 PLANET ARGON.tmbundle
    drwxr-xr-x   3 robbyrus  robbyrus  102 Feb 11 21:10 RSpec.tmbundle
    drwxr-xr-x   4 robbyrus  robbyrus  136 Oct 21 13:38 Robby Russell???s Bundle.tmbundle
&lt;/code&gt;&lt;/pre&gt;

	&lt;h2&gt;Importing your Bundle into Subversion&lt;/h2&gt;


	&lt;p&gt;You&amp;#8217;ll want to first import your new bundle into Subversion.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
    $ cd ~/Library/Application\ Support/TextMate/Bundles/
    $ svn import RSpec.tmbundle/ -m "Initial import of RSpec (test) bundle" http://{respository_url}/{repository_name}/RSpec.tmbundle/
    Adding         RSpec.tmbundle/info.plist
    Adding         RSpec.tmbundle/Snippets
    Adding         RSpec.tmbundle/Snippets/new specification.tmSnippet
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Great, now it&amp;#8217;s in Subversion. Now, you&amp;#8217;ll want to check it back out so that TextMate is running off of the version from Subversion.&lt;/p&gt;


	&lt;p&gt;The simplest way to do this is to delete your local copy and checkout the latest from Subversion.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
    $ rm -rf RSpec.tmbundle/; svn co http://{respository_url}/{repository_name}/RSpec.tmbundle/
    A    RSpec.tmbundle/Snippets
    A    RSpec.tmbundle/Snippets/new specification.tmSnippet
    A    RSpec.tmbundle/info.plist
    Checked out revision 5.
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;All that you need to do now, is relaod your bundles again. Now that you know where the bundle files are stored, you can commit any changes as they are made.&lt;/p&gt;


	&lt;h2&gt;Committing Bundle Changes&lt;/h2&gt;


	&lt;p&gt;When you make changes to your TextMate bundle, you can do the following to commit your updates to the Subversion repository.&lt;/p&gt;


	&lt;h3&gt;See Your Pending Changes&lt;/h3&gt;


	&lt;p&gt;You can change directories to your custom bundle and run &lt;code&gt;svn status&lt;/code&gt;.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
    $ cd ~/Library/Application\ Support/TextMate/Bundles/RSpec.tmbundle/
    $ svn status
    ?      Snippets/new context.tmSnippet
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;You&amp;#8217;ll see that the new snippet that I created needs to be added to Subversion.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
    $ svn add Snippets/new\ context.tmSnippet 
    A         Snippets/new context.tmSnippet
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Now, let&amp;#8217;s commit it to the repository.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
$ svn ci -m "Adding new context snippet" 
Adding         Snippets/new context.tmSnippet
Transmitting file data .
Committed revision 6.
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;At this point, all Subversion tips and tricks apply&amp;#8230; so&amp;#8230; it&amp;#8217;s time to leave it to you to figure out the rest. :-)&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;TIP&lt;/span&gt;: Always reload your bundles before and after running svn update or svn commit&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;...and there you have it! You and your friends can (with a little work) share and develop your own custom bundles for TextMate. I&amp;#8217;m hoping to get my teammates at &lt;a href="http://www.planetargon.com/"&gt;&lt;span class="caps"&gt;PLANET ARGON&lt;/span&gt;&lt;/a&gt; to help me build a bunch for RSpec, which I&amp;#8217;ll try to release into the wild soon. If anybody is already working on RSpec snippets and other TextMate hacks, please let me know.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.robbyonrails.com/articles/2007/02/11/sharing-custom-textmate-bundles-with-subversion#comments"&gt;Aslak kindly commented&lt;/a&gt; on this post and has pointed me to bundle available in the RSpec subversion repository, which I &lt;a href="http://www.robbyonrails.com/articles/2007/02/12/rspec-bundle-for-textmate"&gt;blogged about.&lt;/a&gt;) :-)&lt;/p&gt;


	&lt;p&gt;Happy hacking!&lt;/p&gt;
</description>
      <pubDate>Sun, 11 Feb 2007 23:35:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:f8505a28-84eb-43ea-8504-2d60385d1460</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2007/02/11/sharing-custom-textmate-bundles-with-subversion</link>
      <category>Ruby on Rails</category>
      <category>Programming</category>
      <category>PLANET ARGON</category>
      <category>rspec</category>
      <category>textmate</category>
      <category>subversion</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Install Ruby, Rails, and PostgreSQL on OSX</title>
      <description>&lt;div class="warning"&gt;
&lt;strong&gt;&lt;span class="caps"&gt;WARNING&lt;/span&gt;:&lt;/strong&gt; This post contains some outdated instructions. Please read &lt;a href="http://www.robbyonrails.com/articles/2007/06/19/installing-ruby-on-rails-and-postgresql-on-os-x-second-edition"&gt; Installing Ruby on Rails and PostgreSQL on &lt;span class="caps"&gt;OS X&lt;/span&gt;, Second Edition&lt;/a&gt;.
&lt;/div&gt;

	&lt;p&gt;Our Creative Director, Allison Beckwith, picked up a new black MacBook this weekend and I had the luxury of getting it setup to model our standard setup. We all try to keep our setups fairly similar so that we don&amp;#8217;t hit too many issues when working together on projects.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ll try to keep this short and to the point&amp;#8230; because if you&amp;#8217;re like me&amp;#8230; you just want to start playing with Rails! ;-)&lt;/p&gt;


	&lt;p&gt;The steps I followed to get her setup like the rest of the development team at &lt;a href="http://www.planetargon.com"&gt;&lt;span class="caps"&gt;PLANET ARGON&lt;/span&gt;&lt;/a&gt; went something like this.&lt;/p&gt;


	&lt;h3&gt;XCode and DarwinPorts&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;Download and install &lt;a href="http://iterm.sf.net/"&gt;iterm&lt;/a&gt; (the Universal dmg)&lt;/li&gt;
		&lt;li&gt;Download and install XCode tools from Apple (dmg)&lt;/li&gt;
		&lt;li&gt;Download and install &lt;a href="http://darwinports.opendarwin.org/"&gt;DarwinPorts&lt;/a&gt; (dmg)&lt;/li&gt;
		&lt;li&gt;Start up iterm.&lt;/li&gt;
	&lt;/ul&gt;


In this step we are going to modify the default bash profile so that every user on the machine that uses bash will get the path for darwinports in their bash_profile.
&lt;pre&gt;&lt;code&gt;sudo vi /etc/profile&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Modify the following line to include &lt;code&gt;/opt/local/bin&lt;/code&gt; in the &lt;span class="caps"&gt;PATH&lt;/span&gt;&amp;#8230; save the file (see vim documentation for details)&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  PATH="/bin:/sbin:/opt/local/bin:/usr/bin:/usr/sbin" 
&lt;/code&gt;&lt;/pre&gt;

	&lt;h3&gt;Ruby and Rails&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;Open up a new iterm tab (apple-t)&lt;/li&gt;
		&lt;li&gt;Install ruby with darwinports with: &lt;code&gt;sudo port install ruby rb-rubygems&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Install Ruby on Rails and all its dependencies with: &lt;code&gt;sudo gem install -y rails&lt;/code&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;h3&gt;PostgreSQL and Ruby libs&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;Install PostgreSQL8 with: &lt;code&gt;sudo port install postgresql8&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;We need to modify the &lt;code&gt;/etc/profile&lt;/code&gt; file again because the postgresql8 install doesn&amp;#8217;t add programs like pg_ctl to /opt/local/bin. Change the &lt;span class="caps"&gt;PATH&lt;/span&gt; to now look like this and save.&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;
  PATH="/bin:/sbin:/opt/local/bin:/usr/bin:/usr/sbin:/opt/local/lib/pgsql8/bin" 
&lt;/code&gt;&lt;/pre&gt;

	&lt;ul&gt;
	&lt;li&gt;Install the &lt;strong&gt;postgres&lt;/strong&gt; gem with: &lt;code&gt;sudo gem install postgres&lt;/code&gt;
	&lt;ul&gt;
	&lt;li&gt;Oh NO!!! You should see an error about it not finding libraries&amp;#8230; what will we do?&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;
  cd /opt/local/lib/ruby/gems/1.8/gems/postgres-0.7.1
  sudo ruby extconf.rb --with-pgsql-include=/opt/local/include/pgsql8 --with-pgsql-lib=/opt/local/lib/pgsql8
  sudo make &amp;#38;&amp;#38; sudo make install
  # for good measure...
  sudo gem install postgres
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;&lt;strong&gt;Successfully installed postgres-0.7.1&lt;/strong&gt;&lt;/p&gt;


	&lt;h3&gt;Configure PostgreSQL for single user&lt;/h3&gt;


	&lt;p&gt;In our development environments, we don&amp;#8217;t find it necessary to keep PostgreSQL running all the time on our servers. We only want it running when we&amp;#8217;re doing development. We also typically install it per user on a machine to keep us from needing things like usernames and passwords to connect to it from an application we&amp;#8217;re running on the machine. Let&amp;#8217;s setup PostgreSQL the &lt;span class="caps"&gt;PLANET ARGON&lt;/span&gt; way!&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Open up iterm and go to your home directory&lt;/li&gt;
		&lt;li&gt;Init your new PostgreSQL database with: &lt;code&gt;initdb -D pgdata&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Start up PostgreSQL with: &lt;code&gt;pg_ctl -D pgdata -l pgdata/psql.log start&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Create a new database with: &lt;code&gt;createdb argon_development&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Test the new database with: &lt;code&gt;psql argon_development&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Did it load up your new database? If so, great! If not&amp;#8230; check your steps&amp;#8230; :-)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h3&gt;Test Rails + PostgreSQL&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;Navigate to a directory where you don&amp;#8217;t mind sticking projects&amp;#8230; &lt;code&gt;mkdir development; cd development&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Generate a new Rails application with: &lt;code&gt;rails -d postgresql argon&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Navigate to new Rails application directory. &lt;code&gt;cd argon&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Generate a new model to test with: &lt;code&gt;./script/generate model Argonista&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Edit and save the migration that was generated ( &lt;code&gt;db/migrate/001_create_argonistas.rb&lt;/code&gt; ) file with your favorite editor&amp;#8230;&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;
  class CreateArgonistas &amp;lt; ActiveRecord::Migration
    def self.up
      create_table :argonistas do |t|
        t.column :name, :string
        t.column :blog_url, :string
      end
    end

    def self.down
      drop_table :argonistas
    end
  end
&lt;/code&gt;&lt;/pre&gt;

	&lt;ul&gt;
	&lt;li&gt;Edit &lt;code&gt;config/database.yml&lt;/code&gt; to look like the following&amp;#8230; you&amp;#8217;ll notice that we don&amp;#8217;t need to supply a username or password.&lt;/li&gt;
	&lt;/ul&gt;


&lt;pre&gt;&lt;code&gt;
  development:
    adapter: postgresql
    database: argon_development

  test:
    adapter: postgresql 
    database: argon_test

  production:
    adapter: postgresql
    database: argon_production
&lt;/code&gt;&lt;/pre&gt;

* Run the migration with: &lt;code&gt;rake db:migrate&lt;/code&gt;
&lt;pre&gt;&lt;code&gt;
  $ rake db:migrate
  (in /Users/allisonbeckwith/development/argon)
  == CreateArgonistas: migrating ================================================
  -- create_table(:argonistas)
  NOTICE:  CREATE TABLE will create implicit sequence "argonistas_id_seq" for serial column "argonistas.id" 
  NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "argonistas_pkey" for table "argonistas" 
     -&amp;gt; 0.0399s
  == CreateArgonistas: migrated (0.0402s) =======================================
&lt;/code&gt;&lt;/pre&gt;

* Test your new model from console
&lt;pre&gt;&lt;code&gt;
  $ ./script/console 
  Loading development environment.
  &amp;gt;&amp;gt; a = Argonista.new
  =&amp;gt; #&amp;lt;Argonista:0x24569dc @attributes={"name"=&amp;gt;nil, "blog_url"=&amp;gt;nil}, @new_record=true&amp;gt;
  &amp;gt;&amp;gt; a.name = 'Robby'
  =&amp;gt; "Robby" 
  &amp;gt;&amp;gt; a.blog_url = 'http://www.robbyonrails.com'
  =&amp;gt; "http://www.robbyonrails.com" 
  &amp;gt;&amp;gt; a.save
  =&amp;gt; true
  &amp;gt;&amp;gt; exit
&lt;/code&gt;&lt;/pre&gt;

* Great, let&amp;#8217;s go look at our database table&amp;#8230;
&lt;pre&gt;&lt;code&gt;
  $ psql argon_development
  Welcome to psql 8.1.3, the PostgreSQL interactive terminal.

  Type:  \copyright for distribution terms
         \h for help with SQL commands
         \? for help with psql commands
         \g or terminate with semicolon to execute query
         \q to quit

  argon_development=# SELECT * FROM argonistas;
   id | name  |          blog_url           
  ----+-------+-----------------------------
    1 | Robby | http://www.robbyonrails.com
  (1 row)
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;There we go, we&amp;#8217;ve setup Ruby, Rails, and PostgreSQL on a brand new Intel MacBook without breaking a sweat!&lt;/p&gt;


	&lt;h3&gt;Extra Goodies&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;Subversion: &lt;code&gt;sudo port install subversion&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Lighttpd: &lt;code&gt;sudo port install lighttpd&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;ImageMagick: &lt;code&gt;sudo port install ImageMagick&lt;/code&gt; (known to take a while&amp;#8230;)&lt;/li&gt;
		&lt;li&gt;GraphicsMagick: &lt;code&gt;sudo port install GraphicsMagick&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Install the rmagick gem: &lt;code&gt;sudo gem install rmagick&lt;/code&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Have fun!&lt;/p&gt;</description>
      <pubDate>Mon, 29 May 2006 09:46:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6faf4e72-89d7-433c-8e6a-059509001562</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2006/05/29/install-ruby-rails-and-postgresql-on-osx</link>
      <category>Ruby on Rails</category>
      <category>Ruby</category>
      <category>Programming</category>
      <category>PostgreSQL</category>
      <category>PLANET ARGON</category>
      <category>osx</category>
      <category>tutorial</category>
      <category>postgresql</category>
      <category>rubyonrails</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
