<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Empty Thoughts - Home</title>
  <id>tag:blog.railsconsulting.com,2007:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://blog.railsconsulting.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://blog.railsconsulting.com/" rel="alternate" type="text/html"/>
  <updated>2007-07-22T13:24:06Z</updated>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-07-22:41</id>
    <published>2007-07-22T13:23:00Z</published>
    <updated>2007-07-22T13:24:06Z</updated>
    <link href="http://blog.railsconsulting.com/2007/7/22/blog-is-moving" rel="alternate" type="text/html"/>
    <title>Blog is Moving</title>
<content type="html">
            &lt;p&gt;This blog is moving to blog.michaeltrier.com.  No real reason except that I&#8217;m trying to consolidate some things.  Please change your subscriptions accordingly.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-07-22:40</id>
    <published>2007-07-22T13:15:00Z</published>
    <updated>2007-07-22T13:21:37Z</updated>
    <category term="Django"/>
    <link href="http://blog.railsconsulting.com/2007/7/22/django-on-gentoo-dog-linux" rel="alternate" type="text/html"/>
    <title>Django on Gentoo (DoG) Linux</title>
<content type="html">
            &lt;p&gt;Django on Gentoo (DoG) Linux image. This is built on the base Gentoo image that I posted about &lt;a href=&quot;http://developer.amazonwebservices.com/connect/thread.jspa?threadID=15345&#38;tstart=15&quot;&gt;previously&lt;/a&gt; . I added a whole bunch of goodness to run Django. Included are a whole set of startup scripts that build up the system and initialize the application. &lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;&lt;strong&gt;AMI ID:&lt;/strong&gt; ami-29947140
&lt;strong&gt;AMI Manifest:&lt;/strong&gt; eminent-ami/django/10/image.manifest.xml&lt;/code&gt;&lt;/pre&gt;


	&lt;h4&gt;About this &lt;span class=&quot;caps&quot;&gt;AMI&lt;/span&gt;&lt;/h4&gt;


	&lt;p&gt;This image contains a Gentoo Linux 2007.0 installation with Django application support.  The following applications / libraries are installed and/or configured:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Gentoo Linux
	&lt;ul&gt;
	&lt;li&gt;dhcpcd,&lt;/li&gt;
		&lt;li&gt;logrotate,&lt;/li&gt;
		&lt;li&gt;all packages are recent and updated,&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;AMI&lt;/span&gt; tools have been installed and are fully working even for volume imaging,&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;EC2&lt;/span&gt; meta-data is fetched from 169.254.169.254 into /var/spool/ec2/meta-data,&lt;/li&gt;
		&lt;li&gt;&lt;span class=&quot;caps&quot;&gt;EC2&lt;/span&gt; meta-data and user-data include files in /var/spool/ec2/meta-data and /var/spool/ec2/user-data respectively,&lt;/li&gt;
		&lt;li&gt;Disabled password authentication in /etc/ssh/sshd_config&lt;/li&gt;
		&lt;li&gt;Modifications to startup according to Amazon documentation&lt;/li&gt;
		&lt;li&gt;the portage tree has been bind-mounted to /mnt/usr/portage to preserve space on the root file system,&lt;/li&gt;
		&lt;li&gt;the /tmp directory has been bind-mounted to /mnt/tmp to preserve space,&lt;/li&gt;
		&lt;li&gt;the /var/lib/postgresql directory has been bind-mounted to /mnt/var/lib/postgresql,&lt;/li&gt;
		&lt;li&gt;the root home directory contains a dev-copy directory that is needed to build the volume images,&lt;/li&gt;
		&lt;li&gt;all packages have been recompiled to correctly respect the Xen environment.&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;ul&gt;
	&lt;li&gt;Django
	&lt;ul&gt;
	&lt;li&gt;Apache 2.2.4 installed (not in startup) and configured with Python support,&lt;/li&gt;
		&lt;li&gt;Python 2.5.1,&lt;/li&gt;
		&lt;li&gt;mod_python,&lt;/li&gt;
		&lt;li&gt;Postgresql 8.2.4 (not in startup),&lt;/li&gt;
		&lt;li&gt;psycopg2&lt;/li&gt;
		&lt;li&gt;Subversion 1.4.3 (no repositories are setup)&lt;/li&gt;
		&lt;li&gt;Django trunk version checked out into /home/django/django and installed as normal into the Python site-packages directory (django-admin.py copied to /usr/local/bin/),&lt;/li&gt;
		&lt;li&gt;Support packages: libjpgeg, zlib, freetype2, zip, and unzip,&lt;/li&gt;
		&lt;li&gt;Python packages: &lt;span class=&quot;caps&quot;&gt;PIL 1&lt;/span&gt;.1.6, FeedParser 4.1, Markdown 1.6, Unipath 0.1,&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;ul&gt;
	&lt;li&gt;This image contains the following daemons / services:
	&lt;ul&gt;
	&lt;li&gt;local&lt;/li&gt;
		&lt;li&gt;net.eth0 / net.eth1&lt;/li&gt;
		&lt;li&gt;netmount&lt;/li&gt;
		&lt;li&gt;dhcpcd&lt;/li&gt;
		&lt;li&gt;sshd&lt;/li&gt;
		&lt;li&gt;syslog-ng&lt;/li&gt;
		&lt;li&gt;vixie-cron&lt;/li&gt;
		&lt;li&gt;apache 2 (disabled by default)&lt;/li&gt;
		&lt;li&gt;postgresql (disabled by default)&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h4&gt;Sample Application&lt;/h4&gt;


	&lt;p&gt;The instance can accept a set of user data parameters for setting up an application. I&#8217;ve provided a default application to indicate the process for creating your own application setup scripts. If you run the instance with the following parameters it will startup a complete running default application based on the Django Vote tutorial.&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;ami-29947140 -k gsg-keypair -d &quot;app=mysite-setup=http://s3.amazonaws.com/eminent-ami/mysite-setup.tgz&quot;[/code]Once the server is up and running you should be able to to enter the public hostname (starts with ec2) into your browser and view the application. The Admin section of the application is in the location /admin. Credentials are:&lt;/code&gt;&lt;/pre&gt;


	&lt;pre&gt;&lt;code&gt;&lt;strong&gt;Username:&lt;/strong&gt; admin
&lt;strong&gt;Password:&lt;/strong&gt; password&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;The default application will be installed into the /home/django/mysite directory. The setup scripts for the application will get installed into /opt/mysite-setup. The Admin media directory and the mysite media directory are both symbolically linked to the /var/www/mysite/htdocs directory.&lt;/p&gt;


	&lt;h4&gt;Postgresql Configuration&lt;/h4&gt;


	&lt;p&gt;Postgresql is installed but there is no database setup and the service is not started by default. The database directory /var/lib/postgresql is bind mounted to /mnt/var/lib/postgresql. The configuration files have been configured according to the Gentoo Postgresql How-To (http://gentoo-wiki.com/HOWTO_Configure_Postgresql) document with the included logging changes. Configuration files are symbolically linked in from /etc/postgresql for those that like that sort of thing. A sample of creating and restoring the database can be found in the mysite-setup scripts for the Sample Application. Write Ahead Logging (WAL) is not implemented, but would be necessary implementation detail for most sites.&lt;/p&gt;


	&lt;h4&gt;Creating an Application Setup Package&lt;/h4&gt;


	&lt;p&gt;The mysite-setup package (http://s3.amazonaws.com/eminent-ami/mysite-setup.tgz) is the base requirements for your own application setup package. At a minimum you are required to have a bin directory with a file in it called setup.sh. Within the setup.sh script you are free to put any setup instructions you need or pass those tasks off to other scripts written in the language of your choice.&lt;/p&gt;


	&lt;p&gt;Currently the configuration of this image requires that the application setup package is publicly available and downloadable via curl (see the application-setup.sh script). I plan to add security implementation details in the future.&lt;/p&gt;


	&lt;h2&gt; &lt;strong&gt;Thanks&lt;/strong&gt;&lt;/h2&gt;


	&lt;p&gt;Grateful thanks to &lt;a href=&quot;http://developer.amazonwebservices.com/connect/entry.jspa?externalID=620&#38;categoryID=101&quot;&gt;Geert Bevin&lt;/a&gt; for his initial Gentoo image.&lt;/p&gt;


	&lt;p&gt;Special thanks to &lt;a href=&quot;http://info.rightscale.com/&quot;&gt;RightScale&lt;/a&gt; for ideas and guidance provided by their startup scripts&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-07-15:36</id>
    <published>2007-07-15T04:11:00Z</published>
    <updated>2007-07-15T04:23:38Z</updated>
    <category term="Django"/>
    <link href="http://blog.railsconsulting.com/2007/7/15/django-goodness" rel="alternate" type="text/html"/>
    <title>Django Goodness</title>
<content type="html">
            &lt;p&gt;For the past several months I&#8217;ve been head down learning Python and &lt;a href=&quot;http://www.djangoproject.com/&quot;&gt;Django&lt;/a&gt;.  Why you ask?  Well I believe in using the right tool for the job.  I&#8217;m working on a new project that Django lends itself to.  Could I have written it in Rails?  Sure, probably.  But it wouldn&#8217;t be the best choice.  I&#8217;m all about being pragmatic, and always looking for an opportunity to learn something new.  So Django it is!&lt;/p&gt;


	&lt;p&gt;As with learning most new things, I was first faced with a lot of frustration in the beginning.  I kept saying things like, &#8220;That&#8217;s stupid.&#8221;  Or, &#8220;Why did they do it that way?&#8221;  But it didn&#8217;t take me long to begin to appreciate the beauty of Django and Python.  There were even moments were I found myself sitting back and just laughing in amazement at all that&#8217;s there.  It is quite elegant, and I look forward to continuing my journey.&lt;/p&gt;


	&lt;p&gt;Anyway, if you start seeing Django related posts, that&#8217;s why.  I&#8217;m still writing a lot of Ruby code, and still enjoy its elegance.  But Django is my newfound love, and it&#8217;s what I&#8217;m eating and breathing these days.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-04-06:35</id>
    <published>2007-04-06T13:00:00Z</published>
    <updated>2007-04-06T13:00:30Z</updated>
    <category term="Plugins"/>
    <category term="Rails"/>
    <link href="http://blog.railsconsulting.com/2007/4/6/hobo-for-rails" rel="alternate" type="text/html"/>
    <title>Hobo for Rails</title>
<content type="html">
            &lt;p&gt;There&#8217;s been some buzz lately about &lt;a href=&quot;http://www.hobocentral.net/&quot;&gt;Hobo&lt;/a&gt;, a plugin extension to the Rails framework that makes it easy to do rapid prototyping of web applications.  You can find out about all of the features at the &lt;a href=&quot;http://www.hobocentral.net/&quot;&gt;HoboCentral&lt;/a&gt; website.  One exciting feature is the implementation of &lt;span class=&quot;caps&quot;&gt;DRYML&lt;/span&gt;, a way of drying up your views and providing extendable tag libraries.&lt;/p&gt;


	&lt;p&gt;Check out the &lt;a href=&quot;http://www.hobocentral.net/screencasts.php&quot;&gt;screencasts&lt;/a&gt;.  They&#8217;re very well done.  I haven&#8217;t been this stunned by a screencast since I saw the original &lt;a href=&quot;http://rubyonrails.com/screencasts&quot;&gt;&lt;span class=&quot;caps&quot;&gt;DHH&lt;/span&gt; Rails screencast&lt;/a&gt;. It&#8217;s exciting times.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-04-06:34</id>
    <published>2007-04-06T12:31:00Z</published>
    <updated>2007-04-06T12:33:06Z</updated>
    <category term="Rails"/>
    <category term="Testing"/>
    <link href="http://blog.railsconsulting.com/2007/4/6/stubbing-authentication-in-your-controllers" rel="alternate" type="text/html"/>
    <title>Stubbing Authentication in Your Controllers</title>
<content type="html">
            &lt;p&gt;I was trying to spec out a few of my controllers that had actions on them requiring authentication.  After jumping through many mind hoops to figure out how to stub them out properly I asked the &lt;a href=&quot;http://rubyforge.org/mailman/listinfo/rspec-users&quot;&gt;RSpec-Users&lt;/a&gt; list and received this solution from &lt;a href=&quot;http://blog.imperialdune.com/&quot;&gt;Graeme Nelson&lt;/a&gt;:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def mock_user_authentication(allow_user_to_pass=true)       
  controller.stub!(:login_required).and_return(allow_user_to_pass)
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;It&#8217;s elegantly simple and works well. I&#8217;m still fumbling around with this &lt;a href=&quot;http://rspec.rubyforge.org/&quot;&gt;RSpec&lt;/a&gt; stuff and did not realize I could stub out a method directly on the controller.  This has cleared up a big missing piece in my thinking.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-04-03:32</id>
    <published>2007-04-03T16:56:00Z</published>
    <updated>2007-04-03T16:58:36Z</updated>
    <category term="Rails"/>
    <link href="http://blog.railsconsulting.com/2007/4/3/railscasts" rel="alternate" type="text/html"/>
    <title>Railscasts</title>
<content type="html">
            &lt;p&gt;Ryan Bates provides an excellent collection of &lt;a href=&quot;http://www.railscasts.com/&quot;&gt;Ruby on Rails screencasts&lt;/a&gt; for &lt;strong&gt;free&lt;/strong&gt;.  If you have a couple of minutes, literally, please check out what he&#8217;s put together.&lt;/p&gt;


	&lt;p&gt;Some time ago I had envisioned producing something similar, but in no way could I have even come close to this.  Ryan really nails it, with high production quality and keeping it concise.  &lt;a href=&quot;http://blog.railsconsulting.com/2007/3/19/pay-it-forward&quot;&gt;Show him some love&lt;/a&gt;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-04-03:31</id>
    <published>2007-04-03T16:45:00Z</published>
    <updated>2007-04-06T13:01:56Z</updated>
    <category term="Plugins"/>
    <category term="Rails"/>
    <link href="http://blog.railsconsulting.com/2007/4/3/textile-editor" rel="alternate" type="text/html"/>
    <title>Textile Editor</title>
<content type="html">
            &lt;p&gt;The fine folks developing &lt;a href=&quot;http://slateinfo.blogs.wvu.edu&quot;&gt;Slate&lt;/a&gt;, a content management system for Rails,  have just released a &lt;a href=&quot;http://slateinfo.blogs.wvu.edu/plugins&quot;&gt;Textile Editor plugin&lt;/a&gt;.  This works well in conjunction with &lt;a href=&quot;http://errtheblog.com/&quot;&gt;Err the Blog&#8217;s&lt;/a&gt; &lt;a href=&quot;http://agilewebdevelopment.com/plugins/acts_as_textiled&quot;&gt;acts_as_textiled&lt;/a&gt; plugin.&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://blog.railsconsulting.com/assets/2007/4/3/textile_editor.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-03-30:28</id>
    <published>2007-03-30T14:07:00Z</published>
    <updated>2007-03-30T14:09:24Z</updated>
    <link href="http://blog.railsconsulting.com/2007/3/30/softerra-ldap-browser" rel="alternate" type="text/html"/>
    <title>Softerra LDAP Browser</title>
<content type="html">
            &lt;p&gt;If you find yourself having to navigate &lt;span class=&quot;caps&quot;&gt;LDAP&lt;/span&gt; structures, &lt;a href=&quot;http://www.softerra.com/&quot;&gt;Softerra&lt;/a&gt; has a very nice freeware version of an &lt;a href=&quot;http://www.ldapbrowser.com/download.htm&quot;&gt;&lt;span class=&quot;caps&quot;&gt;LDAP&lt;/span&gt; Browser&lt;/a&gt;.  It is a lightweight alternative to their pay for product &lt;a href=&quot;http://www.ldapbrowser.com&quot;&gt;Softerra &lt;span class=&quot;caps&quot;&gt;LDAP&lt;/span&gt; Administrator&lt;/a&gt;.  It only works on Windows OS.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-03-30:27</id>
    <published>2007-03-30T03:47:00Z</published>
    <updated>2007-03-30T03:57:34Z</updated>
    <category term="Rails"/>
    <link href="http://blog.railsconsulting.com/2007/3/30/ecstatic-cloud" rel="alternate" type="text/html"/>
    <title>Ecstatic Cloud</title>
<content type="html">
            &lt;p&gt;After months of waiting patiently, I was finally informed that my &lt;a href=&quot;http://aws.amazon.com/ec2&quot; title=&quot;EC2&quot;&gt;elastic cloud&lt;/a&gt; account was available.  If you&#8217;re not familiar with all of the cool things &lt;a href=&quot;http://aws.amazon.com&quot;&gt;Amazon Web Services&lt;/a&gt; is doing, I recommend you spend some time getting acquainted with their offerings.  I&#8217;ve been using &lt;a href=&quot;http://aws.amazon.com/s3&quot;&gt;S3&lt;/a&gt;, their storage solution, for some time now, and I&#8217;m definitely stoked about playing around with &lt;span class=&quot;caps&quot;&gt;EC2&lt;/span&gt;.  This on the heals of &lt;a href=&quot;http://jnewland.com/&quot;&gt;Jesse Newland&#8217;s&lt;/a&gt; announcement of &lt;a href=&quot;http://rubyforge.org/projects/capazon/&quot;&gt;Capazone&lt;/a&gt;, a &lt;a href=&quot;http://manuals.rubyonrails.com/read/book/17&quot;&gt;Capistrano&lt;/a&gt; task library for managing &lt;span class=&quot;caps&quot;&gt;EC2&lt;/span&gt; servers.  Like I needed one more thing to distract me from all the projects I should be working on.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-03-30:26</id>
    <published>2007-03-30T03:43:00Z</published>
    <updated>2007-03-30T03:47:28Z</updated>
    <category term="Rails"/>
    <link href="http://blog.railsconsulting.com/2007/3/30/lighthouse-released" rel="alternate" type="text/html"/>
    <title>Lighthouse Released</title>
<content type="html">
            &lt;p&gt;&lt;a href=&quot;http://activereload.net/&quot;&gt;ActiveReload&lt;/a&gt;, a new company by Justin Palmer and Rick Olson (of Mephisto fame), just announced the release of &lt;a href=&quot;http://www.lighthouseapp.com/&quot;&gt;Lighthouse&lt;/a&gt;.  Lighthouse is a simple and elegant issue tracking software as a service application.  Signup for free account and give it a whirl.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-03-29:25</id>
    <published>2007-03-29T01:07:00Z</published>
    <updated>2007-04-06T12:30:39Z</updated>
    <category term="Rails"/>
    <link href="http://blog.railsconsulting.com/2007/3/29/restful-change" rel="alternate" type="text/html"/>
    <title>RESTful Change</title>
<content type="html">
            &lt;p&gt;Subscribing to the &lt;a href=&quot;http://dev.rubyonrails.org/timeline&quot;&gt;&lt;span class=&quot;caps&quot;&gt;RSS&lt;/span&gt; Change Log&lt;/a&gt; feed to the Subversion repository for Ruby on Rails is a great way to stay on top of what&#8217;s going on in Rails land and helps to give you a leg up on the types of things that are coming down the pipe.  Today I saw &lt;a href=&quot;http://dev.rubyonrails.org/changeset/6485&quot;&gt;Changeset 6485&lt;/a&gt; and it was quickly blogged about by &lt;a href=&quot;http://pragdave.pragprog.com/pragdave/2007/03/change_to_rest_.html&quot;&gt;Dave Thomas&lt;/a&gt;.  This changeset removes the use of the semicolon in RESTful routes and reverts it back to the old slash way of indicating sub resource intent.  What this means is that a route like:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;/categories/1;edit&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;will now become (or should I say become once again)&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;/categories/1/edit&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;In addition we get niceties like:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;/categories/recent
/categories/1/stamp&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;I&#8217;ve never liked having the semicolon in the url; it just smelled of ugliness. I think we&#8217;ll find that this change is a good one and one that allows us to have the benefit of RESTful urls while still allowing for legitimate variations on that theme to support sub resources.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-03-27:24</id>
    <published>2007-03-27T17:12:00Z</published>
    <updated>2007-04-06T13:01:29Z</updated>
    <category term="Rails"/>
    <category term="Testing"/>
    <link href="http://blog.railsconsulting.com/2007/3/27/mocking-restful-routes" rel="alternate" type="text/html"/>
    <title>Mocking RESTful Routes</title>
<content type="html">
            &lt;p&gt;I just spent about an hour trying to figure out why none of my RESTful routes were working properly within my &lt;a href=&quot;http://rspec.rubyforge.org/&quot;&gt;RSpec&lt;/a&gt; controller specs.  In my controller I had some boilerplate code like this:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;# POST /categories
# POST /categories.xml
def create
  @category = Category.new(params[:category])

  respond_to do |format|
    if @category.save
      flash[:notice] = 'Category was successfully created.'
      format.html { redirect_to category_url(@category) }
      format.xml  { head :created, :location =&amp;gt; category_url(@category) }
    else
      format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }
      format.xml  { render :xml =&amp;gt; @category.errors.to_xml }
    end
  end
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The line causing the problem was:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;redirect_to category_url(@category)&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;I kept receiving an error on the eval of &lt;code&gt;category_url&lt;/code&gt; with an error description of &#8220;can&#8217;t convert Fixnum into String&#8221;.&lt;/p&gt;


	&lt;p&gt;I tried replacing @category with @category.id to see if I would get different results.  The error went away but the test failed indicating that the id returned from the @category instance was not the same as I was expecting.  This led me to determine that I needed to stub out the id property on my class.  So I added the following to my setup:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;@category.stub!(:id).and_return(1)&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Everything worked.  Problem solved.  But wait, that&#8217;s ugly and smells of something wrong.  I should be able to just pass the object to the &lt;code&gt;category_url&lt;/code&gt; and have it return the correct value.  What I did next was go down a rat hole trying to figure out what the named route was sending to the object to get the id.  I had assumed &lt;code&gt;id&lt;/code&gt;, but in fact it&#8217;s &lt;code&gt;to_param&lt;/code&gt;, which I had already stubbed out as follows:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;@category = mock_model(Category, :to_param =&amp;gt; 1)&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;So what&#8217;s the problem?  It turns out that &lt;code&gt;to_param&lt;/code&gt; must return a string.  Makes sense.  I changed it to the following and everything worked perfectly:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;@category = mock_model(Category, :to_param =&amp;gt; &amp;quot;1&amp;quot;)&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;It&#8217;s little things like this that make learning so much fun.  This issue is really indicative of a much bigger problem&#8212;my lack of understanding mocks and stubs.  But, I&#8217;ll have more to write about this later.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-03-24:23</id>
    <published>2007-03-24T00:48:00Z</published>
    <updated>2007-03-24T00:48:52Z</updated>
    <link href="http://blog.railsconsulting.com/2007/3/24/writing-a-book" rel="alternate" type="text/html"/>
    <title>Writing a Book</title>
<content type="html">
            &lt;p&gt;I&#8217;ve really been enjoying &lt;a href=&quot;http://pragdave.pragprog.com/pragdave/&quot;&gt;Dave Thomas&#8217; PragDave blog&lt;/a&gt; series on &lt;a href=&quot;http://pragdave.pragprog.com/pragdave/writing_a_book/index.html&quot;&gt;Writing a Book&lt;/a&gt;. In this series of posts Dave Thomas gives some guidance for those whom desire to write a book, or may be in the process of writing a book.&lt;/p&gt;


	&lt;p&gt;A long time ago in another life I was very close to accepting an agreement to write a book for Jeff Duntemann&#8217;s now defunct publishing company The Coriolis Group. Due to a lot of circumstances, mostly personal, I decided not to do it.  It was the right decision at the time, but I have nonetheless thought about writing a book ever since.  Perhaps someday the opportunity will present itself once again, and I&#8217;ll have both the time and the right life situation to follow through with it.&lt;/p&gt;


	&lt;p&gt;If writing a book is something you&#8217;ve thought about or posted on your list of &lt;a href=&quot;http://www.43things.com/&quot;&gt;43 Things&lt;/a&gt;, take advantage of Dave Thomas&#8217; helpful notes.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-03-19:22</id>
    <published>2007-03-19T23:47:00Z</published>
    <updated>2007-03-19T23:49:38Z</updated>
    <category term="Ruby"/>
    <link href="http://blog.railsconsulting.com/2007/3/19/pay-it-forward" rel="alternate" type="text/html"/>
    <title>Pay it Forward</title>
<content type="html">
            &lt;p&gt;It&#8217;s that time of year again.  Yes, when we all have the privilege of calculating how much
money we get to fork over to Uncle Sam.  But, it&#8217;s also a nice annual reminder, for those of us
that have the privilege of programming in Ruby, that we are the fortunate ones.  Last year 
at this time someone on the Ruby-Talk mailing list suggested that individuals that made 
their livelihood by programming in Ruby, should do something to benefit the community at large.  
And, I agree.&lt;/p&gt;


	&lt;p&gt;So if you&#8217;re wondering what to do, how you can help out, in what way you can give back, wonder
no more.  There are many ways to help out.  In the Rails community there are individuals
like &lt;a href=&quot;http://weblog.jamisbuck.org/&quot;&gt;Jamis Buck&lt;/a&gt; devoting a significant amount of time to produce in-depth quality documentation
on the internals of Rails.  Drop a dime in his tip jar next time you think of it.  But Jamis isn&#8217;t the only one. 
There are many other individuals out there that are working hard, contributing to open
source projects, and lending a hand in general.  Feel free to 
&lt;a href=&quot;http://www.imdb.com/title/tt0223897/&quot;&gt;Pay it Forward&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Perhaps you should consider giving a donation to &lt;a href=&quot;http://www.rubycentral.org/&quot;&gt;Ruby Central, Inc.&lt;/a&gt; 
If you don&#8217;t know who Ruby Central is, it&#8217;s a non-profit organization founded to support Ruby 
internationally. Ruby Central is run by &lt;a href=&quot;http://chadfowler.com/&quot;&gt;Chad Fowler&lt;/a&gt;, 
&lt;a href=&quot;http://www.rubypowerandlight.com/&quot;&gt;David Black&lt;/a&gt;, and &lt;a href=&quot;http://richkilmer.blogs.com/&quot;&gt;Rich Kilmer&lt;/a&gt;.  
They are responsible for putting on the annual International Ruby Conference, 
the Rails Conference, and several regional conferences as well.  At RubyConf 2006 in 
Denver, Colorado a participant asked Matz how the community at large could best support the 
development of Ruby and the team that is working on the future of Ruby.  Matz replied that he 
thought the best way to support Ruby was to support Ruby Central, the public international 
voice for Ruby.  Sounds good to me.&lt;/p&gt;


	&lt;p&gt;Last year I made a commitment to donate a portion of the money I made from writing Ruby code 
to support the Ruby community at large.  Why don&#8217;t you join me and together we can do our
part to keep programmers writing happy code.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.railsconsulting.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:blog.railsconsulting.com,2007-03-18:21</id>
    <published>2007-03-18T13:05:00Z</published>
    <updated>2007-03-18T13:08:04Z</updated>
    <category term="Rails"/>
    <category term="Testing"/>
    <link href="http://blog.railsconsulting.com/2007/3/18/overtesting-who-cares" rel="alternate" type="text/html"/>
    <title>Overtesting, Who Cares?</title>
<content type="html">
            As I indicated in a &lt;a href=&quot;http://blog.railsconsulting.com/2007/3/16/advanced-rails-training&quot;&gt;prior post&lt;/a&gt; I&#8217;m beginning to wrap my head around &lt;a href=&quot;http://rspec.rubyforge.org/&quot;&gt;Rspec&lt;/a&gt; 
and use it in a new 
project that I&#8217;m working on.  I recently came across a post where someone had written
something similar to the following, indicating a spec for &lt;code&gt;has_many&lt;/code&gt; and
&lt;code&gt;belongs_to&lt;/code&gt; in a model.

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;context &amp;quot;A Category with fixtures loaded&amp;quot; do
  fixtures :listings, :categories

  specify &amp;quot;should have many Listings&amp;quot; do
    l = categories(:cars).listings
    l.should_not be_nil
    l.should_not be_empty
    l.first.should be_an_instance_of Listing
  end
end&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;One of the comments to the blog post was critical of this approach suggesting that this
spec was validating Rails code and that the author should focus only on code that he / she
has written.  I&#8217;ve seen this argument several times in the past and this issue actually 
came up briefly in the &lt;a href=&quot;http://blog.railsconsulting.com/2007/3/16/advanced-rails-training&quot;&gt;Advanced Rails Training&lt;/a&gt; course in Chicago.&lt;/p&gt;


	&lt;p&gt;While I agree that you shouldn&#8217;t be testing Rails code, that&#8217;s not what is going on here.
The spec is for the existence of the defined relationships within the model, and that things
are wired up properly to enable accessing the relationship properly within the model.  If someone
were to inadvertently remove the &lt;code&gt;has_many&lt;/code&gt; method call in the model the spec
would fail, which is exactly the behavior we want.&lt;/p&gt;


	&lt;p&gt;Secondly, even if we were testing Rails code, I think it&#8217;s better to error on the side
of overcoverage than to not write tests at all.  It is important that developers
are not so overwhelmed with the &#8220;right&#8221; or &#8220;wrong&#8221; way to do testing that testing is 
not done at all.&lt;/p&gt;


	&lt;p&gt;The above code actually comes from a project I&#8217;m working on.  This blog post aside, if you 
have recommendations on how it should be done differently, please let me know.&lt;/p&gt;
          </content>  </entry>
</feed>
