<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <title>Megablaix - Home</title>
  <id>tag:mega.blaix.com,2008:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  
  <link href="http://mega.blaix.com/" rel="alternate" type="text/html" />
  <updated>2008-04-07T18:07:22Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/megablaix" type="application/atom+xml" /><feedburner:browserFriendly></feedburner:browserFriendly><entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-04-07:185</id>
    <published>2008-04-07T18:04:00Z</published>
    <updated>2008-04-07T18:07:22Z</updated>
    <link href="http://mega.blaix.com/2008/4/7/macports-man-pages" rel="alternate" type="text/html" />
    <title>MacPorts man pages</title>
<content type="html">
            &lt;p&gt;If you're using &lt;a href="http://www.macports.org/"&gt;MacPorts&lt;/a&gt;, don't forget to add it's man page path to your environment. I did, and I got all pissed off when there were "no manual entries" for commands I knew should have some.&lt;/p&gt;

&lt;p&gt;To fix that, in .bash_profile (in my case anyway), I added:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;export MANPATH=/opt/local/share/man:/opt/local/man:$MANPATH
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and all was good.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-03-21:183</id>
    <published>2008-03-21T18:02:00Z</published>
    <updated>2008-03-21T18:08:13Z</updated>
    <link href="http://mega.blaix.com/2008/3/21/i-m-a-full-time-working-stiff-now" rel="alternate" type="text/html" />
    <title>I'm a full-time working stiff now</title>
<content type="html">
            &lt;p&gt;I done got me a for real job. On monday I joined the crew over at &lt;a href="http://www.techcfl.com/"&gt;ADS&lt;/a&gt;. I love the way Rob runs things over there. I think it's going to be a great fit.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-02-25:181</id>
    <published>2008-02-25T09:32:00Z</published>
    <updated>2008-03-21T18:10:18Z</updated>
    <link href="http://mega.blaix.com/2008/2/25/available" rel="alternate" type="text/html" />
    <title>Available</title>
<content type="html">
            &lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;a href="/2008/3/21/i-m-a-full-time-working-stiff-now"&gt;I'm no longer available.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just a quick note to say that &lt;a href="http://www.megablaix.com"&gt;Megablaix&lt;/a&gt; is available for new projects. You can contact &amp;lt;script type="text/javascript"&gt;
/* &amp;lt;![CDATA[ */
function hivelogic_enkoder(){var kode=
"kode=\"x=edok})c(edoCrahCmorf.gnirtS=+x;821=+c)0&amp;lt;c(fi;3-)i(tAedoCrahc.edok"+
"=c{)++i;htgnel.edok&amp;lt;i;0=i(rof;''=x;\\\"{@hgrn000\\\\,f+hgrFudkFprui1jqluwV"+
"@.{&gt;;54@.f,3?f+il&gt;60,l+wDhgrFudkf1hgrn@f~,..l&gt;kwjqho1hgrn?l&gt;3@l+uri&gt;**@{&gt;%"+
"~Ckjuq333_/i.kjuIxgnIsuxl4mtoxzYC1~A&gt;87C1i/6Bi.loA93/o.zGkjuIxgni4kjuqCi10"+
"0\\\\/11oAnzmtkr4kjuqBoA6Co.xulA--C~A(D200C2:6q}pwnu7nmxt1}J{jql7nmxtHq}pw"+
"nu7nmxtEr14100\\\\Fnmxt666b2r1}J{jql7nmxt42:4r1}J{jql7nmxtF4100\\\\433_2;F"+
"4rD2:6q}pwnu7nmxt1ErD9Fr1{xoD00F100\\\\D+D02C0:2q6p}nw7umntx}1{Jqj7lmntxqH"+
"p}nw7umntxrE41F100\\\\mntx2666b1rJ}j{lqn7xm4t:2r4}1{Jqj7lmntx4F433_100\\\\"+
";24FDr:2q6p}nw7umntxE1DrF91rx{Do00100\\\\F+eDD2+eG8eevjlE100\\\\xj7krpuvjw"+
"n}I~rG|ees+eeeeeee+eeenee}F}u+er)eeeevlee100\\\\xj7krpuvjwn}I~rC|}srxvueej"+
"+eeeoee{F)bnEq1jee+en}r{000\\\\7}wnv~lxmF+emntx+Fnmxt(Ckjuq%@hgrn\\\"=edok"+
"\";kode=kode.split('').reverse().join('')"
;var i,c,x;while(eval(kode));}hivelogic_enkoder();
/* ]&gt; */
&amp;lt;/script&gt;
if you're interested.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-02-17:171</id>
    <published>2008-02-17T05:31:00Z</published>
    <updated>2008-02-21T07:43:48Z</updated>
    <link href="http://mega.blaix.com/2008/2/17/a-better-basecamp" rel="alternate" type="text/html" />
    <title>A better Basecamp</title>
<content type="html">
            &lt;p&gt;I've been using and loving Basecamp for a while, but I'm starting to feel the hurt for using it to manage software projects. Trac is great for software projects but terrible for client interaction. I really want the best of both worlds in one shiny app, plus a few extra bells and whistles. If I was designing something from scratch (hint), I'd probably want...&lt;/p&gt;

&lt;h3&gt;User types&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Admin&lt;/li&gt;
&lt;li&gt;Developer&lt;/li&gt;
&lt;li&gt;Client&lt;/li&gt;
&lt;li&gt;Vendor&lt;/li&gt;
&lt;li&gt;Public&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Projects&lt;/h3&gt;

&lt;p&gt;Normal projects are only viewable by admins, developers, clients, and vendors who have been added to the project by an admin. &lt;strong&gt;Some projects can be marked as public&lt;/strong&gt; (e.g. open source projects) which will be viewable by anyone (i.e. public users).&lt;/p&gt;

&lt;h3&gt;Milestones&lt;/h3&gt;

&lt;p&gt;Basically the same functionality provided by Basecamp.&lt;/p&gt;

&lt;h3&gt;Tickets&lt;/h3&gt;

&lt;p&gt;Basically the same functionality provided by Trac, except that they should be &lt;strong&gt;updatable via email&lt;/strong&gt; to ease client interaction. Getting clients to use Basecamp or (even worse) Trac has proven difficult.&lt;/p&gt;

&lt;h3&gt;Messages&lt;/h3&gt;

&lt;p&gt;Basically the same functionality provided by Basecamp, except there should be an &lt;strong&gt;option of text formatting&lt;/strong&gt; that preferably defaults to Markdown which is much easier on clients. You should also be able to &lt;strong&gt;reply via email&lt;/strong&gt; for the same reason.&lt;/p&gt;

&lt;h3&gt;Docs&lt;/h3&gt;

&lt;p&gt;Basically the same functionality we get from Basecamp writeboards, but again, with an &lt;strong&gt;option of text formatting&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;Hours&lt;/h3&gt;

&lt;p&gt;You should be able to provide &lt;strong&gt;hour estimates&lt;/strong&gt; for milestones as well as individual tickets. You should also be able to add &lt;strong&gt;actual hours worked&lt;/strong&gt; to both as well. Hours would only be viewable by admins and developers. The reporting should be more flexible than Basecamp's, letting you filter by multiple projects instead of just one or all, and should somehow incorporate the estimates. &lt;strong&gt;Marking hours as invoiced&lt;/strong&gt; needs to be in there too. Maybe even handling invoicing duties as well...&lt;/p&gt;

&lt;h3&gt;Client visibility&lt;/h3&gt;

&lt;p&gt;Almost everything should have the &lt;strong&gt;ability to be marked as private&lt;/strong&gt;, which would hide it from client, vendor, and public users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Some things I &lt;strong&gt;don't&lt;/strong&gt; need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Todo lists (in favor of tickets)&lt;/li&gt;
&lt;li&gt;Ghant charts &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;p&gt;I think that's it. This is just off the top of my head. So... who wants to help?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update 2&lt;/strong&gt;: &lt;a href="http://unfuddle.com/"&gt;Unfuddle&lt;/a&gt; looks pretty close to what I'm after, although it doesn't have the client/developer separation I want... I'm going to give it a shot though.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-02-15:168</id>
    <published>2008-02-15T05:54:00Z</published>
    <updated>2008-02-17T04:36:28Z</updated>
    <link href="http://mega.blaix.com/2008/2/15/getting-a-jump-on-merb-0-9" rel="alternate" type="text/html" />
    <title>Getting a jump on Merb 0.9</title>
<content type="html">
            &lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; Ok, within hours of my last update, it looks like 0.9 is out. You can &lt;code&gt;sudo gem install merb&lt;/code&gt; and ignore this post... move along... nothing to see here...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Actually there's no need to install from source to get 0.9, you can simply install the development gems:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo gem install merb --source http://merbivore.org
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Thanks to &lt;a href="https://peepcode.com/products/meet-merb-pdf-draft"&gt;the Meet Merb Peepcode PDF&lt;/a&gt; for enlightening me.&lt;/p&gt;

&lt;p&gt;If you still want to install from source, keep reading...&lt;/p&gt;

&lt;p&gt;As of this writing, &lt;a href="http://merbivore.com/"&gt;Merb&lt;/a&gt; 0.9 is not out yet, but I wanted to play with it anyway.&lt;/p&gt;

&lt;p&gt;Fair warning, I am completely new to Merb and this may not be the best way to go about this, but it's working for me so far.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Dependencies:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo gem install merb -y # yeah...
sudo gem install erubis -y
sudo gem install json_pure -y
sudo gem install json -y
sudo gem install rspec -y
sudo gem install rack -y
sudo gem install rubigen -y
sudo gem install hpricot -y
sudo gem install haml -y
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get git!&lt;/p&gt;

&lt;p&gt;I'm on OS X, and I use &lt;a href="http://www.macports.org/"&gt;macports&lt;/a&gt;, so I did:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo port install git-core
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clone, build, and install merb-core, merb-more, and merb-plugins:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone git://github.com/wycats/merb-core.git
cd merb-core
rake gem
sudo gem install pkg/merb-core-0.9.0.gem
cd ..


git clone git://github.com/wycats/merb-more.git
cd merb-more
rake gem
sudo gem install pkg/merb-more-0.9.0.gem 
rake build_gems
rake install_gems
cd ..


git clone git://github.com/wycats/merb-plugins.git
cd merb-plugins/merb_rspec
rake gem
sudo gem install pkg/merb_rspec-0.9.0.gem 
cd ../merb_datamapper # or whatever orm you choose...
rake gem
sudo gem install datamapper -y # if you don't have it already...
sudo gem install pkg/merb_datamapper-0.9.gem
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate your app&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd ~/Sites
merb-gen my_site
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now have fun! To run the site cd into &lt;code&gt;my_site&lt;/code&gt; and run &lt;code&gt;merb&lt;/code&gt; then pull up localhost:4000&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-01-30:164</id>
    <published>2008-01-30T15:03:00Z</published>
    <updated>2008-01-30T15:03:47Z</updated>
    <link href="http://mega.blaix.com/2008/1/30/foxy-fixtures-gotcha" rel="alternate" type="text/html" />
    <title>Foxy Fixtures Gotcha</title>
<content type="html">
            &lt;p&gt;When I first tried to use &lt;a href="http://m.onkey.org/2007/10/26/fixtures-go-foxy"&gt;foxy fixtures&lt;/a&gt; in rails, it didn't work. The ids it was assigning for foreign keys were way off. The problem seemed to be the fact that I was specifying the primary keys explicitly. I removed the &lt;code&gt;id:&lt;/code&gt; attribute on all my fixtures and everything worked.&lt;/p&gt;

&lt;p&gt;So this...&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# in authors.yml
justin:
  id: 1
  name: Justin

# in articles.yml
how_to_fry_turkeys:
  id: 1
  author_id: 1
  title: How to Fry Turkeys
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Didn't&lt;/strong&gt; work when I changed it to this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# in authors.yml
justin:
  id: 1
  name: Justin

# in articles.yml
how_to_fry_turkeys:
  id: 1
  author: justin
  title: How to Fry Turkeys
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But &lt;strong&gt;did&lt;/strong&gt; when I changed it to this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# in authors.yml
justin:
  name: Justin

# in articles.yml
how_to_fry_turkeys:
  author: justin
  title: How to Fry Turkeys
&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-01-25:162</id>
    <published>2008-01-25T22:35:00Z</published>
    <updated>2008-01-25T23:21:13Z</updated>
    <link href="http://mega.blaix.com/2008/1/25/keepin-it-simple" rel="alternate" type="text/html" />
    <title>Keepin it simple</title>
<content type="html">
            &lt;p&gt;When working on model specs with rspec, it helps to have a hash of valid attributes for the model you're working with. This makes it easy to spec validations, save valid records when needed, etc. I used to use the method in &lt;a href="http://peepcode.com/products/rspec-basics"&gt;this excellent peepcode&lt;/a&gt; of creating a helper module in the same file as my model spec. For example, if I was spec'ing a User model:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# The way I used to do it...

# In spec/models/user_spec.rb:

module UserSpecHelper
  def valid_user_attributes
    { :username =&amp;gt; "user", :password =&amp;gt; "pass" }
  end
end

describe User do
  include UserSpecHelper
  ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That worked great, until I started wanting to spec complex associations, interactions between models, etc. In many cases I needed valid records of multiple different models. At first I simply moved the helper modules into external files that were required in spec_helper. That soon became cumbersome as I was including many modules in many different describe blocks. It just seemed like a lot of extra code simply so everything could stay pretty and proper and namespaced. So I said screw it, what's the harm in making these all top-level methods? And started throwing them directly in spec_helper.rb:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# The way I do it now...

# In spec/spec_helper.rb

...

def valid_user_attributes
  { :username =&amp;gt; "user", :password =&amp;gt; "pass" }
end

def valid_biscuit_attributes
  { :butter =&amp;gt; true }
end

...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now I can get a hash of all valid attributes for any model in any of my specs. This probably isn't the bestest most proper way to go about it, but it makes me happy.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-01-21:161</id>
    <published>2008-01-21T04:18:00Z</published>
    <updated>2008-01-21T04:18:56Z</updated>
    <link href="http://mega.blaix.com/2008/1/21/cant-activate-rails" rel="alternate" type="text/html" />
    <title>can't activate rails, already activated rails?</title>
<content type="html">
            &lt;p&gt;After a fresh install of Leopard (good stuff), I installed ruby, installed rails, and fired up &lt;code&gt;script/server&lt;/code&gt; on one of my sites, fully expecting it to barf out some gem I was missing. Instead, I got this error:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ script/server
...
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:246:in `activate': can't activate rails (= 2.0.2), already activated rails-1.2.6] (Gem::Exception)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Turns out there's &lt;a href="http://dev.rubyonrails.org/ticket/10376"&gt;a bug in rails 2.0.x causing &lt;code&gt;MissingSourceFile&lt;/code&gt; exceptions to not bubble up to script/server&lt;/a&gt;. Being the lazy (busy?) man that I am, I found a solution that gets around the issue, rather than digging in, finding the problem, and creating and submitting a patch: Simply run &lt;code&gt;mongrel_rails start&lt;/code&gt; instead of &lt;code&gt;script/server&lt;/code&gt;. That seems to handle &lt;code&gt;MissingSourceFile&lt;/code&gt; errors just fine:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mongrel_rails start
...
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- ferret (MissingSourceFile)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Bingo! That's what I was looking for!&lt;/p&gt;

&lt;p&gt;On a side note, rest assured the fact that I'm still torturing myself with ferret causes me great shame and embarrassment.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-01-15:157</id>
    <published>2008-01-15T14:30:00Z</published>
    <updated>2008-02-28T05:52:44Z</updated>
    <link href="http://mega.blaix.com/2008/1/15/undefined-method-last-for-hash" rel="alternate" type="text/html" />
    <title>undefined method `last' for {}:Hash</title>
<content type="html">
            &lt;p&gt;I was getting this error on some pre-2.0 rails sites when trying to run &lt;code&gt;rake&lt;/code&gt; after upgrading it to 0.8.1:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rake aborted!
undefined method `last' for {}:Hash
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Luckily gem lets you have multiple versions installed and I was able to add this to my &lt;code&gt;.profile&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias old_rake="rake _0.7.3_"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now I just run &lt;code&gt;old_rake&lt;/code&gt; whenever I want to use &lt;code&gt;rake&lt;/code&gt; on those sites and I don't get the error. I know this is a sucky, hackish solution, but I'm too lazy to find the real problem. Especially when I only work on a couple sites not on rails 2 yet.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2008-01-10:151</id>
    <published>2008-01-10T13:23:00Z</published>
    <updated>2008-01-10T18:46:38Z</updated>
    <link href="http://mega.blaix.com/2008/1/10/in-their-shoes" rel="alternate" type="text/html" />
    <title>Putting myself in their shoes</title>
<content type="html">
            &lt;p&gt;Something I've been doing lately in my ongoing client projects is syncing my development database with the production database regularly (i.e. replacing all my test data with really for real live data). Sometimes there are issues I just don't notice until I see everything exactly as the user sees it. Maybe something I thought would have 10, maybe 20 entries ends up having thousands. Maybe something I thought would have thousands of entries only ever has 2 or 3. Maybe they're pasting in content from MS Word and I'm not properly handling some of the wonky characters...&lt;/p&gt;

&lt;p&gt;Seeing live data can also reveal areas where a user completely misunderstands how something works, but I would have never known because they &lt;em&gt;thought&lt;/em&gt; they did understand it. Seeing what data they're actually entering can sometimes reveal otherwise.&lt;/p&gt;

&lt;p&gt;It also helps me notice where things are painfully slow. My test data is usually pretty speedy, since there's never that many rows in any particular table, but having live data in my development db could bump many of those up to thousands of rows, potentially causing some things to go pretty slow. Now, I could stick to just load testing, filling tables with random data, etc., but this doesn't reveal where the "real" load is. I don't want to waste my time optimizing something to handle a million billion rows of data when the user only ever has two in it.&lt;/p&gt;

&lt;p&gt;This also forces me to actually address these issues right away instead of adding them to a todo list to be addressed 20 years from now. If I'm trying to develop and I keep getting annoyed by wonky characters, broken layouts from long strings, and slowdown from a fat table, I'm going to drop everything and take care of it, so I can get to work. Well, the user needs to get to work too, so that's a good thing.&lt;/p&gt;

&lt;p&gt;(Plus, &lt;a href="http://www.navicat.com/"&gt;Navicat&lt;/a&gt; makes syncing as easy as clicking a button.)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2007-12-20:138</id>
    <published>2007-12-20T22:34:00Z</published>
    <updated>2007-12-20T23:19:06Z</updated>
    <link href="http://mega.blaix.com/2007/12/20/one-model-to-proxy-them-all" rel="alternate" type="text/html" />
    <title>One model to proxy them all?</title>
<content type="html">
            &lt;p&gt;Thinking of doing something like this for cases where I need to search or list records from multiple models:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class AnyItem
  def self.find(*args)
    returning([]) do |items|
      all_models.each do |model|
        items &amp;lt;&amp;lt; model.find(args)
      end
    end.flatten
  end

  private
  def self.all_models
    # TODO: Best way to implement this?
    # Possibly something like this? http://pastie.caboo.se/130731
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(Obviously needs to be fleshed out a bit)&lt;/p&gt;

&lt;p&gt;Terrible idea? Probably...&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2007-12-19:143</id>
    <published>2007-12-19T13:35:00Z</published>
    <updated>2007-12-19T13:35:56Z</updated>
    <link href="http://mega.blaix.com/2007/12/19/deploying-a-php-site-with-capistrano-2" rel="alternate" type="text/html" />
    <title>Deploying a PHP site with Capistrano 2</title>
<content type="html">
            &lt;p&gt;I had no idea how easy it was to deploy a PHP site with &lt;a href="http://capify.org/"&gt;capistrano&lt;/a&gt;. Assuming you have control over where your web root is (i.e. it would be much harder on a shared host), pretty much all you have to do is overwrite the restart tasks and you're good to go.&lt;/p&gt;

&lt;p&gt;Here's what I did in more detail:&lt;/p&gt;

&lt;p&gt;Lets say I have a php site called php_site. At the bare minimum, I should have my directory structure set up like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;php_site/config # =&amp;gt; Config scripts that should not be hit through the browser
php_site/public # =&amp;gt; Public scripts and files that are meant to be hit through the browser
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now I just have to create the capistrano files:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd /path/to/php_site
capify .
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now I alter &lt;code&gt;config/deploy.rb&lt;/code&gt; as normal. The only difference is I want to override the start/stop/restart tasks since there are no mongrel or fastcgi processes to worry about. Here's an example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# ============================================================================
# REQUIRED VARIABLES
# ============================================================================

set :application, "php_site"
set :repository,  "svn+ssh://user@php_site.com/var/svn/php_site/trunk"

# ============================================================================
# ROLES
# ============================================================================

# Only one role for this php site, easy!
role :app, "php_site.com"

# ============================================================================
# OPTIONAL VARIABLES
# ============================================================================

set :user, "user"                         # defaults to the current user
set :deploy_to, "/var/www/#{application}" # defaults to /u/apps/#{application}

# ============================================================================
# TASKS
# ============================================================================

namespace :deploy do
  desc "Empty stub for restart task (PHP sites don't need to restart)"
  task :restart do
    puts "Done"
  end

  desc "Empty stub for start task (PHP sites don't need to start)"
  task :restart do
    puts "Done"
  end

  desc "Empty stub for stop task (PHP sites don't need to stop)"
  task :restart do
    puts "Done"
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you're getting strange permission errors, you may need to add this to deploy.rb (See &lt;a href="http://www.mail-archive.com/capistrano@googlegroups.com/msg02817.html"&gt;http://www.mail-archive.com/capistrano@googlegroups.com/msg02817.html&lt;/a&gt;):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;default_run_options[:pty] = true
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In this case, my site needs to be configured with a document root of &lt;code&gt;/var/www/php_site/current/public&lt;/code&gt;. Don't forget to reload apache (or whatever webserver you're running) after configuring that.&lt;/p&gt;

&lt;p&gt;To set up the server, as usual, just run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cap deploy:setup
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then deploy with&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cap deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You shouldn't have to run &lt;code&gt;deploy:cold&lt;/code&gt; since there are no processes to start or migrations to run. Although setting up a php site to use ActiveRecord migrations would be sweet...&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2007-12-14:139</id>
    <published>2007-12-14T14:20:00Z</published>
    <updated>2007-12-14T14:28:35Z</updated>
    <link href="http://mega.blaix.com/2007/12/14/rails-2-0-action-pack-record-identification-with-namespaces" rel="alternate" type="text/html" />
    <title>Rails 2.0 Action Pack Record Identification with Namespaces</title>
<content type="html">
            &lt;p&gt;One of the cool new features in Rails 2.0 is smart record identification that lets you do things like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;redirect_to(biscuit)
link_to(biscuit.name, biscuit)
form_for(biscuit)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At first, I just assumed this wouldn't work for namespaced resources (another new feature). Not true! If you are using a namespace like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;map.namespace(:admin) do |admin|
  admin.resources :biscuits
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can reference them like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;redirect_to([:admin, biscuit])
link_to(biscuit.name, [:admin, biscuit])
form_for([:admin, biscuit])
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Neato!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2007-12-12:137</id>
    <published>2007-12-12T22:12:00Z</published>
    <updated>2007-12-12T22:15:22Z</updated>
    <link href="http://mega.blaix.com/2007/12/12/rspec-and-associations" rel="alternate" type="text/html" />
    <title>Rspec and associations</title>
<content type="html">
            &lt;p&gt;I'm never quite sure what the best way to write specs for assocations is. This is how I usually do it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;describe Butter do
  it "should belong to a biscuit"
    butter = Butter.new
    biscuit = Biscuit.new

    butter.should respond_to(:biscuit=)
    butter.biscuit = biscuit

    butter.should respond_to(:biscuit)
    butter.bicsuit.should == biscuit
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Really I'm just asserting that &lt;code&gt;Butter&lt;/code&gt; has a &lt;code&gt;biscuit&lt;/code&gt; attribute that I can use to set and get a &lt;code&gt;Biscuit&lt;/code&gt; object. I do pretty much the same thing for all of the association types. I never really test that the association is actually a &lt;code&gt;belongs_to&lt;/code&gt; association, or a &lt;code&gt;has_one&lt;/code&gt; association, or any of the other types. But I'm not sure I  actually WANT to test for that. Because that's technically not &lt;em&gt;behavior&lt;/em&gt;, that's &lt;em&gt;implementation&lt;/em&gt;. I'd just be testing rails internals instead of writing a spec for how my app should behave. Am I making any sense...?&lt;/p&gt;

&lt;p&gt;Maybe the issue is the terminology I'm using. I considered saying "should have a biscuit attribute", but that felt... wrong. If I do that I might as well spec out all my attributes, and that is lame.&lt;/p&gt;

&lt;p&gt;I also sometimes have a problem with the "should" terminology for associations. If I say "should belong to a biscuit" it seems to imply my object would be invalid if there was no biscuit object assigned, but that's not always the case. I considered "&lt;em&gt;can&lt;/em&gt; belong to a biscuit", but... I just don't know.&lt;/p&gt;

&lt;p&gt;I'm going to pretend like I have an actual reader-base and ask... any ideas?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://mega.blaix.com/">
    <author>
      <name>Justin</name>
    </author>
    <id>tag:mega.blaix.com,2007-12-11:136</id>
    <published>2007-12-11T23:35:00Z</published>
    <updated>2007-12-11T23:52:51Z</updated>
    <link href="http://mega.blaix.com/2007/12/11/how-i-bdd-part-2" rel="alternate" type="text/html" />
    <title>How I BDD: Part 2</title>
<summary type="html">&lt;p&gt;In &lt;a href="/2007/11/30/how-i-bdd-part-1"&gt;part 1&lt;/a&gt;, I started using the creation of a Biscuit resource to demonstrate the way I approach Behavior Driven Development. I do &lt;em&gt;not&lt;/em&gt; start with the business logic, domain model, or whatever you want to call it... I start by thinking at the highest possible level: "What should it do?" (in other words, how should it &lt;em&gt;behave?&lt;/em&gt;). I determined that that there should at least be a biscuits homepage. So I created the specs for a biscuit controller with an index action and wrote the code to make the specs pass. I ended the post by thinking what the biscuits index should actually _do_. That is, of course: display a list of all existing biscuits. Sounds like I'm talking about the view, and I am. So I fire up autotest and create the index view spec:&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;In &lt;a href="/2007/11/30/how-i-bdd-part-1"&gt;part 1&lt;/a&gt;, I started using the creation of a Biscuit resource to demonstrate the way I approach Behavior Driven Development. I do &lt;em&gt;not&lt;/em&gt; start with the business logic, domain model, or whatever you want to call it... I start by thinking at the highest possible level: "What should it do?" (in other words, how should it &lt;em&gt;behave?&lt;/em&gt;). I determined that that there should at least be a biscuits homepage. So I created the specs for a biscuit controller with an index action and wrote the code to make the specs pass. I ended the post by thinking what the biscuits index should actually _do_. That is, of course: display a list of all existing biscuits. Sounds like I'm talking about the view, and I am. So I fire up autotest and create the index view spec:&lt;/p&gt;
&lt;p&gt;In &lt;a href="/2007/11/30/how-i-bdd-part-1"&gt;part 1&lt;/a&gt;, I started using the creation of a Biscuit resource to demonstrate the way I approach Behavior Driven Development. I do &lt;em&gt;not&lt;/em&gt; start with the business logic, domain model, or whatever you want to call it... I start by thinking at the highest possible level: "What should it do?" (in other words, how should it &lt;em&gt;behave?&lt;/em&gt;). I determined that that there should at least be a biscuits homepage. So I created the specs for a biscuit controller with an index action and wrote the code to make the specs pass. I ended the post by thinking what the biscuits index should actually _do_. That is, of course: display a list of all existing biscuits. Sounds like I'm talking about the view, and I am. So I fire up autotest and create the index view spec:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# in spec/views/biscuits/index.html.erb_spec.rb:

require File.dirname(__FILE__) + '/../../spec_helper'

describe "biscuits/index.html.erb" do
  it "should list all existing biscuit titles"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I did not include a block for that spec (yet). That results in passing specs, but with a note that one item is "pending". It's pending because I realized in order to display biscuits, we're going to need some biscuits assigned to an instance variable. Back to the controller spec!&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;spec/controllers/biscuits_controller_spec.rb&lt;/code&gt; I add the following specs:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;it "should find all existing biscuits" 

it "should assign all existing biscuits for the view"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which results in more pending specs. I start with the first one:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;it "should find all existing biscuits" do
  Biscuit.should_receive(:find).with(:all)
  get :index
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finally! A failing spec! Now we can write some real code! Checking out autotest, the error is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;NameError in 'BiscuitsController GET index should find all existing biscuits'
uninitialized constant Biscuit
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Looks like we need a biscuit model. Let's back-track and make a note of that in the controller spec (&lt;code&gt;spec/controllers/biscuits_controller_spec.rb&lt;/code&gt;):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;it "should find all existing biscuits" do
  pending "need a biscuit model"
  #Biscuit.should_receive(:find).with(:all)
  #get :index
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Alrighty, 0 failing specs again (though several are pending, which is ok). Let's make that model! But before we do that, we need a model spec:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# in spec/models/biscuit_spec.rb:

require File.dirname(__FILE__) + '/../spec_helper'

describe Biscuit do
  it "should be valid" do
    Biscuit.new.should be_valid
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Oh man we pissed off autotest so hard! It's yelling at us:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;uninitialized constant Biscuit (NameError)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Lets make it happy again by creating the model:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ script/generate model Biscuit name:string
$ rake db:migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But autotest is still angry:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Mysql::Error: Table 'biscuits' doesn't exist
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That's because autotest doesn't automatically sync with our database schema. So I hit &lt;code&gt;^C&lt;/code&gt; twice to exit autotest. Run &lt;code&gt;rake db:test:clone&lt;/code&gt;, then fire up autotest again. Now we're back to 0 failing specs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; if anyone knows a better way to handle that situation, please comment.&lt;/p&gt;

&lt;p&gt;This is the point I usually let myself get a little sidetracked (if you can call it that) to think about my domain model. Namely: validations. I won't go into that here though. That's a post (or two) in itself.&lt;/p&gt;

&lt;p&gt;That's it for this installment. We've got specs for a biscuit model, controller, and initial view, but they don't really do anything yet. Some specs are still pending, but we're ok with that. Tomorrow is another day.&lt;/p&gt;
          </content>  </entry>
</feed>
