<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>it's a ruby thing - Home</title>
  <id>tag:its.arubything.com,2008:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.7.3">Mephisto Noh-Varr</generator>
  <link href="https://its.arubything.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="https://its.arubything.com/" rel="alternate" type="text/html"/>
  <updated>2007-11-05T23:07:48Z</updated>
  <entry xml:base="https://its.arubything.com">
    <author>
      <name>brandon.dimcheff</name>
    </author>
    <id>tag:its.arubything.com,2007-09-21:8</id>
    <published>2007-09-21T03:00:00Z</published>
    <updated>2007-11-05T23:07:48Z</updated>
    <category term="Tips"/>
    <category term="acts_as_solr"/>
    <category term="associations"/>
    <category term="bdd"/>
    <category term="has_many"/>
    <category term="rails"/>
    <category term="testing"/>
    <category term="tip"/>
    <link href="http://its.arubything.com/2007/9/21/test-behavior-not-implementation" rel="alternate" type="text/html"/>
    <title>Test behavior, not implementation!</title>
<content type="html">
            &lt;p&gt;This is a based on a comment I made on a &lt;a href=&quot;http://giantrobots.thoughtbot.com/2007/9/19/ruby-on-rails-testing-strategies&quot;&gt;post&lt;/a&gt; on thoughtbot&#8217;s blog.  I suggest you read the original post for some background on what I&#8217;m talking about.&lt;/p&gt;

&lt;p&gt;If you&#8217;re too lazy to read, here&#8217;s the basic gist:  You could potentially test your associations or plugins (such as acts_as_solr) by simply checking whether or not your object responds to the messages that the plugins generate when their class methods are called.&lt;/p&gt;

&lt;p&gt;The problem is, we should be trying to test &lt;em&gt;behavior&lt;/em&gt;, not simply whether or not acts_as_solr or has_many are being called.  The problem with the approach described above is that it assumes too much about implementation details and doesn&#8217;t actually make sure your app is doing what it&#8217;s supposed to be doing.  &lt;/p&gt;

&lt;p&gt;In this case, I think that find_by_solr should be called find_by_content or something, since it doesn&#8217;t really matter that it&#8217;s solr that&#8217;s doing the lookup.  All the developer using the API cares about is that when they pass a particular query into the method, the proper results are returned.  And that is what our tests should test.&lt;/p&gt;

&lt;p&gt;I am not convinced that (as many test/rspec examples show) simply checking for association methods (has_many, belongs_to, etc.) or plugin methods (acts_as_solr) are sufficient, or even a good idea at all.  Nor do I think that those sorts of tests qualify as BDD.  For instance, I have something resembling the following in an application per someone&#8217;s suggestion:&lt;/p&gt;

&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;co&quot;&gt;Person&lt;/span&gt;.reflect_on_association(&lt;span class=&quot;sy&quot;&gt;:addresses&lt;/span&gt;).should_not be_nil&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;I really don&#8217;t like this, though.  I don&#8217;t care one bit that there&#8217;s an association called &#8220;addresses&#8221; on my Person object.  What I care about is that Person responds to addresses and that addresses returns an array of the &lt;em&gt;proper&lt;/em&gt; addresses.  This is the whole point in BDD.  Care about the behavior of your objects, not their implementation.&lt;/p&gt;

&lt;p&gt;To explore this further, I&#8217;ll use a slightly more complicated example.  Say I have the following in my Person class:&lt;/p&gt;

&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# app/models/person.rb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;has_many &lt;span class=&quot;sy&quot;&gt;:addresses&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;has_many &lt;span class=&quot;sy&quot;&gt;:cool_addresses&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:foreign_key&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;address_id&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:conditions&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;foo = ? AND bar = ?&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, foo, bar], &lt;span class=&quot;sy&quot;&gt;:order&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:zipcode&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;And the corresponding test case:&lt;/p&gt;

&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;co&quot;&gt;Person&lt;/span&gt;.reflect_on_association(&lt;span class=&quot;sy&quot;&gt;:cool_addresses&lt;/span&gt;).should_not be_nil&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;Well, guess what.  This association exists.  Our tests pass.  But it&#8217;s &lt;em&gt;wrong&lt;/em&gt;.  That :foreign_key is supposed to be person_id and not address_id.  Well, we can solve that!  Just test to make sure the has_many receives the appropriate parameters.  Something like this (made up) helper would work:&lt;/p&gt;

&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;co&quot;&gt;Person&lt;/span&gt;.reflect_on_association(&lt;span class=&quot;sy&quot;&gt;:cool_addresses&lt;/span&gt;).should have_foreign_key(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;person_id&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;))&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;And we could go about our business, basically duplicating all the parameters supplied to has_many in our tests.  But in the end, this is just going to make our tests horribly brittle and is not actually testing anything useful.  It&#8217;s not testing behavior &lt;em&gt;at all&lt;/em&gt;.  &lt;/p&gt;

&lt;p&gt;The whole point in BDD is to make our tests poke and prod our application in a certain way and have them spit back the correct output.  Yes, the plugins/associations are well tested and I shouldn&#8217;t be testing them again.  I know that if my has_many call supplies the correct parameters, I will get the objects I expect to get.  But I still need to make sure that I&#8217;m calling has_many properly.  It&#8217;s simply not sufficient for me to know &lt;em&gt;that&lt;/em&gt; has_many is called, I need to know that &lt;em&gt;when&lt;/em&gt; it&#8217;s called, the proper &#8220;stuff&#8221; happens.  I need to make sure the association does what I expect it to do.  Here&#8217;s what I think my tests should do to ensure cool_addresses is working properly (no real code this time):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a few objects to the Addresses table, either using fixtures or in some kind of before callback.  (Yes, fixtures suck, etc.)&lt;/li&gt;
&lt;li&gt;Make sure cool_addresses returns addresses that correspond to the &#8216;foo&#8217; and &#8216;bar&#8217; conditions above.&lt;/li&gt;
&lt;li&gt;Make sure that cool_addresses returns the addresses ordered by zipcode.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that&#8217;s it.  Yes, it will take the tests slightly longer to run, since they&#8217;re using the database (and maybe fixtures).  Yes, I&#8217;m partially testing ActiveRecord.  But I&#8217;m testing that my object &lt;em&gt;behaves&lt;/em&gt; like I want it to.  That&#8217;s the point in BDD, right?&lt;/p&gt;

&lt;p&gt;As an added benefit, the tests are &lt;em&gt;much&lt;/em&gt; more flexible now.  Check it out:&lt;/p&gt;

&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# app/models/person.rb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;has_many &lt;span class=&quot;sy&quot;&gt;:addresses&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;#has_many :cool_addresses, :foreign_key =&amp;gt; &amp;quot;address_id&amp;quot;, :conditions =&amp;gt; [&amp;quot;foo = ? AND bar = ?&amp;quot;, foo, bar], :order =&amp;gt; :zipcode&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;cool_addresses&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  addresses.find_all &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; {|a| a.foo == foo &amp;amp;&amp;amp; a.bar == bar}.sort(&amp;amp;&lt;span class=&quot;sy&quot;&gt;:zipcode&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;That passes my tests, too.  And it should.  But my previous example where I used association introspection would fail miserably.&lt;/p&gt;

&lt;p&gt;This is a major complaint about a lot of the test code examples I see floating around.  Everybody seems to be mocking and stubbing and introspecting to their heart&#8217;s content, but all they seem to be doing in the end is writing the same code twice: once in their implementation, and once in their tests. And so when they change the way their application is implemented (NOTE: I did &lt;em&gt;not&lt;/em&gt; say their application&#8217;s behavior) their tests break.  &lt;/p&gt;

&lt;p&gt;There are two sides to this BDD thing.  First, your tests need to ensure that if you change the behavior of your code, they will fail.  Second, your tests need to still work when your application still behaves the right way, even if you change every single line of code in your application.  Of course, this is nearly impossible to achieve, but at least we can try.&lt;/p&gt;

&lt;p&gt;Thoughts?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="https://its.arubything.com">
    <author>
      <name>brandon.dimcheff</name>
    </author>
    <id>tag:its.arubything.com,2007-08-31:3</id>
    <published>2007-08-31T01:50:00Z</published>
    <updated>2007-09-10T22:09:32Z</updated>
    <category term="Tips"/>
    <category term="controller"/>
    <category term="has_many :through"/>
    <category term="model"/>
    <category term="rails"/>
    <category term="rest"/>
    <category term="tip"/>
    <link href="http://its.arubything.com/2007/8/31/predefined-models-no-different-than-any-others" rel="alternate" type="text/html"/>
    <title>Predefined models?  No different than any others.</title>
<content type="html">
            &lt;p&gt;Earlier today I was trying to figure out how to make a list of potential models to be created.  For example:  I have some &lt;code&gt;User&lt;/code&gt;s and some &lt;code&gt;Group&lt;/code&gt;s.  I have a many-to-many &lt;code&gt;Membership&lt;/code&gt; join model with some &lt;code&gt;has_many :through&lt;/code&gt;s.  The fundamental goal is to provide the user an interface to add Membership models that link a &lt;code&gt;User&lt;/code&gt; to a &lt;code&gt;Group&lt;/code&gt;.  I &lt;em&gt;could&lt;/em&gt; use a bunch of checkboxes, but I&#8217;d rather pull up a list of possible &lt;code&gt;Group&lt;/code&gt;s with little &#8220;add&#8221; links next to them.&lt;/p&gt;

&lt;p&gt;Since I&#8217;m using RESTful controllers, we have a &lt;code&gt;MembershipsController&lt;/code&gt; that implements all the standard methods.  We&#8217;re also nesting our routes such that &lt;code&gt;MembershipsController&lt;/code&gt; nested beneath the &lt;code&gt;UsersController&lt;/code&gt;.  In order to create the Membership, we need to POST to /users/1/memberships.  But how do we get a list of &lt;code&gt;Membership&lt;/code&gt;s that we can quickly add?&lt;/p&gt;

&lt;p&gt;How about modifying &lt;code&gt;MembershipsController.new&lt;/code&gt;?  We don&#8217;t need the normal definition of &lt;code&gt;new&lt;/code&gt;, since we&#8217;re never going to be manually creating a new Membership.&lt;/p&gt;

&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c&quot;&gt;# controllers/memberships_controller.rb&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;new&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;iv&quot;&gt;@memberships&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;Groups&lt;/span&gt;.find(&lt;span class=&quot;sy&quot;&gt;:all&lt;/span&gt;).collect &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |group|&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Membership&lt;/span&gt;.new(&lt;span class=&quot;sy&quot;&gt;:user_id&lt;/span&gt; =&amp;gt; params[&lt;span class=&quot;sy&quot;&gt;:user_id&lt;/span&gt;], &lt;span class=&quot;sy&quot;&gt;:group_id&lt;/span&gt; =&amp;gt; group.id)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;Now we have a list of potential &lt;code&gt;Membership&lt;/code&gt; objects available to our view.  Remember, the &lt;code&gt;Membership&lt;/code&gt;s haven&#8217;t been saved yet.  They&#8217;re just there for convenience for holding attributes.  We are doing object-oriented programming after all.&lt;/p&gt;

&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;# views/memberships/new.html.erb&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;lt;%&lt;/span&gt; &lt;span class=&quot;iv&quot;&gt;@memberships&lt;/span&gt;.each &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |membership| &lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;lt;%&lt;/span&gt; form_for &lt;span class=&quot;sy&quot;&gt;:membership&lt;/span&gt;, membership, &lt;span class=&quot;sy&quot;&gt;:url&lt;/span&gt; =&amp;gt; memberships_path &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |f| &lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;lt;%=&lt;/span&gt; f.hidden_field &lt;span class=&quot;sy&quot;&gt;:user_id&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;lt;%=&lt;/span&gt; f.hidden_field &lt;span class=&quot;sy&quot;&gt;:group_id&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;lt;%=&lt;/span&gt; f.submit membership.group.name &lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;lt;%&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;lt;%&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;Basically what we have here is a big list of predefined join models wrapped up in form tags.  When you click on one of them, you&#8217;ll end up submitting the form that actually creates the model.  Eventually, we could make this into an AJAX widget that uses &lt;code&gt;form_remote_for&lt;/code&gt; with very little effort.&lt;/p&gt;

&lt;p&gt;Nothing I have described here is particularly revolutionary.  Rather than just returning a single new &lt;code&gt;Membership&lt;/code&gt; in the &lt;code&gt;new&lt;/code&gt; method, we return a list of objects.  Rather than rendering one form with editable fields, we render multiple forms with predefined, hidden fields.  Whichever you submit creates the corresponding object.  These two very simple changes to the standard REST actions allow us to easily and elegantly create our join models.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="https://its.arubything.com">
    <author>
      <name>brandon.dimcheff</name>
    </author>
    <id>tag:its.arubything.com,2007-08-28:2</id>
    <published>2007-08-28T03:52:00Z</published>
    <updated>2007-08-30T04:27:02Z</updated>
    <category term="Howto"/>
    <category term="gem"/>
    <category term="install"/>
    <category term="macports"/>
    <category term="mysql"/>
    <category term="rails"/>
    <link href="http://its.arubything.com/2007/8/28/installing-a-rails-stack-on-mac-os-x-with-macports" rel="alternate" type="text/html"/>
    <title>Installing a Rails stack on Mac OS X with MacPorts</title>
<content type="html">
            &lt;p&gt;I have a clean install of OS X on which I need to install Rails.  I&#8217;ve done this maybe 3 or 4 times in the past year with minor variations each time which inevitably come back to bite me later.  This post is an effort to document and standardize all the details to get a Rails stack going with MacPorts.&lt;/p&gt;

&lt;h2&gt;Installing Xcode Tools&lt;/h2&gt;

&lt;p&gt;You need the latest version of &lt;a href=&quot;http://developer.apple.com/tools/xcode/&quot;&gt;Xcode tools&lt;/a&gt; to be able to compile all the packages necessary for Ruby and Rails.  They&#8217;re a free download from Apple.&lt;/p&gt;

&lt;h2&gt;Installing MacPorts&lt;/h2&gt;

&lt;p&gt;First thing&#8217;s first: Install &lt;a href=&quot;http://trac.macosforge.org/projects/macports/wiki/InstallingMacPorts&quot;&gt;MacPorts&lt;/a&gt;! Be sure to follow the directions closely.  Especially the bit about setting your &lt;code&gt;PATH&lt;/code&gt; appropriately.  The /opt paths must be before your standard path so when you type &lt;code&gt;ruby&lt;/code&gt;, you use the ruby interpreter from MacPorts rather than the old one that came with OS X.&lt;/p&gt;

&lt;h2&gt;Installing Rails Prerequisites with MacPorts&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ sudo port install mysql5 +server
$ sudo port install ruby
$ sudo port install rb-rubygems
$ sudo port install rb-mysql
$ sudo port install rb-termios
$ sudo port install subversion +tools
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Configure MySQL&lt;/h2&gt;

&lt;p&gt;First, add &lt;code&gt;/opt/local/lib/mysql5/bin/&lt;/code&gt; to your &lt;code&gt;PATH&lt;/code&gt; as you did in the instructions to install MacPorts.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo mysql_install_db5 --user=mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Install Gems&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install -y rake
$ sudo gem install -y rails
$ sudo gem install -y capistrano
$ sudo gem install -y mongrel
$ sudo gem install -y mongrel_cluster
$ sudo gem install -y piston
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Install Optional Packages&lt;/h2&gt;

&lt;p&gt;The above ports and gems are the minimum you&#8217;ll need to get rails running successfully.  The ones below, while not required, are often useful when developing rails apps.&lt;/p&gt;

&lt;h3&gt;Other Databases&lt;/h3&gt;

&lt;p&gt;Try postgres or sqlite3 for some database variety (&lt;code&gt;port install postgresql82-server &amp;amp;&amp;amp; port install rb-postgres&lt;/code&gt; or &lt;code&gt;port install rb-sqlite3&lt;/code&gt;, respectively).&lt;/p&gt;

&lt;h3&gt;Testing&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://rspec.rubyforge.org/&quot;&gt;RSpec&lt;/a&gt; - a powerful &lt;a href=&quot;http://en.wikipedia.org/wiki/Behavior_driven_development&quot;&gt;BDD&lt;/a&gt; framework&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://flexmock.rubyforge.org/&quot;&gt;Flexmock&lt;/a&gt; and/or &lt;a href=&quot;http://mocha.rubyforge.org/&quot;&gt;Mocha&lt;/a&gt; - for mocking/stubbing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Misc&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://tzinfo.rubyforge.org/&quot;&gt;tzinfo&lt;/a&gt; - Time Zone handling&lt;/li&gt;
&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="https://its.arubything.com">
    <author>
      <name>brandon.dimcheff</name>
    </author>
    <id>tag:its.arubything.com,2007-08-27:1</id>
    <published>2007-08-27T05:10:00Z</published>
    <updated>2007-08-30T04:27:16Z</updated>
    <category term="Announcements"/>
    <category term="admin"/>
    <link href="http://its.arubything.com/2007/8/27/first-post" rel="alternate" type="text/html"/>
    <title>First Post</title>
<content type="html">
            &lt;p&gt;After 9 months of trying to get a Ruby blog launched, I finally have succeeded.  And now it&#8217;s late, so I&#8217;m going to bed.  But check back soon for juicy Ruby and Rails tidbits.&lt;/p&gt;

&lt;p&gt;No, tags don&#8217;t quite work yet.  It&#8217;s Heminway&#8217;s fault.  I&#8217;m fixing it and I&#8217;ll release my changes.&lt;/p&gt;
          </content>  </entry>
</feed>
