<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog - ShiftEleven &#187; fixtures</title>
	<atom:link href="http://shifteleven.com/articles/tag/fixtures/feed" rel="self" type="application/rss+xml" />
	<link>http://shifteleven.com</link>
	<description></description>
	<lastBuildDate>Mon, 09 Jan 2012 04:04:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Loading Fixtures in a Migration</title>
		<link>http://shifteleven.com/articles/2006/09/28/loading-fixtures-in-a-migration?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=loading-fixtures-in-a-migration</link>
		<comments>http://shifteleven.com/articles/2006/09/28/loading-fixtures-in-a-migration#comments</comments>
		<pubDate>Thu, 28 Sep 2006 20:57:23 +0000</pubDate>
		<dc:creator>K. Adam Christensen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[fixtures]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://dev.fecalrod.com/articles/2006/09/28/loading-fixtures-in-a-migration</guid>
		<description><![CDATA[I love migrations I think they are one of the best things about rails. I love that I can count on any changes I&#8217;ve done in the database to be consistent across all other databases that I use. Love it. &#8230; <a href="http://shifteleven.com/articles/2006/09/28/loading-fixtures-in-a-migration">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I love <a href="http://wiki.rubyonrails.org/rails/pages/UnderstandingMigrations.">migrations</a> I think they are one of the best things about rails.  I love that I can count on any changes I&#8217;ve done in the database to be consistent across all other databases that I use.  Love it.</p>
<p>Sometimes I find that I want pre-load my database with some data, like categories that I have.  For testing purposes, I have already created this data in my fixture; now I just want to load that fixture into my database from a migration call.</p>
<p>I know that there is a <code>rake</code> task for this, so I looked into that code and came up with a little something.</p>
<p><span id="more-14"></span></p>
<pre class="ruby" title="code">require 'active_record/fixtures'

class CreateCategories &lt; ActiveRecord::Migration
  def self.up
    create_table :categories do |t|
      t.column :name, :string
    end

    Fixtures.create_fixtures('test/fixtures', File.basename("categories.yml", '.*'))
  end

  def self.down
    drop_table :categories
  end
end</pre>
<p>First I had to require <code>active_record/fixtures</code>.  This allows me to call the <code>Fixtures#create_fixtures</code> method, which load my data.  Now I can gaurantee that my fixture data will be loaded for any environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://shifteleven.com/articles/2006/09/28/loading-fixtures-in-a-migration/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

