<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:ent="http://www.purl.org/NET/ENT/1.0/" version="2.0">
  <channel>
    <title>Curiouser and Curiouser! on fixtures</title>
    <link>http://matt.blogs.it/</link>
    <description>RSS feed for topic fixtures</description>
    <copyright>Copyright 2008 Matt Mower. Some rights reserved.</copyright>
    <generator>Squib/0.5.0.382</generator>
    <managingEditor>self@mattmower.com</managingEditor>
    <webMaster>self@mattmower.com</webMaster>
    <language>en-gb</language>
    <item>
      <title>Down a rathole</title>
      <link>http://matt.blogs.it/entries/00002824.html</link>
      <pubDate>Thu, 10 Apr 2008 23:45:37 +0100</pubDate>
      <description>&lt;p&gt;So today I decided (and now I forget exactly why) to try out the relatively new (Rails 2.0 at least) way of doing fixtures in Rails. It comes from a plugin called Rathole (see &lt;a href="http://ryandaigle.com/articles/2007/10/26/what-s-new-in-edge-rails-fixtures-just-got-a-whole-lot-easier"&gt;here&lt;/a&gt;) and means that instead of:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;companies.yml
  reeplay:
    id: 1
    name: reeplay

employees.yml
  matt:
    id: 1
    name: Matt
    company_id: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;we can do:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;companies.yml
  reeplay:
    name: $LABEL

employees.yml
  matt:
    name: Matt
    company: reeplay
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;by allowing the fixtures to automatically generate the id's a source of brittleness (which anyone who has needed to insert a fixture will be familiar with) is removed. Not to mention the fixtures become smaller and more intelligible. There's a bunch of other nice stuff to do with associations. All in all quite a win.&lt;/p&gt;

&lt;p&gt;If it worked.&lt;/p&gt;

&lt;p&gt;That's the thing, when I change my fixture:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;playlist_x:
  user_id: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;to:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;playlist_x:
  user: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;all I get is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'user' in 'field list'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;which is less than helpful because, of course, there is no &lt;code&gt;user&lt;/code&gt; column that's the whole point. The fixtures should be removing that an inserting an autogenerated id in it's place.&lt;/p&gt;

&lt;p&gt;I have no idea why this isn't working. I'm using Rails 2.0.2 and i've verified that changeset 8036 seems to be there. It's just not working.&lt;/p&gt;

&lt;p&gt;Now I have spent some time converting all my fixtures and none of my tests run which is a bit crippling. Well, that is to say they run, but it takes about 10 minutes to finish printing the complete list of identical exceptions and stack traces.&lt;/p&gt;

&lt;p&gt;If anyone can help me out here it would be much appreciated.&lt;/p&gt;</description>
      <guid isPermaLink="true">http://matt.blogs.it/entries/00002824.html</guid>
      <ent:cloud ent:href="http://matt.blogs.it/topics/">
      </ent:cloud>
    </item>
  </channel>
</rss>
