<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	>
<channel>
	<title>Comments on: Rails Seed Data</title>
	<atom:link href="http://derekdevries.com/2009/04/13/rails-seed-data/feed/" rel="self" type="application/rss+xml" />
	<link>http://derekdevries.com/2009/04/13/rails-seed-data/</link>
	<description></description>
	<pubDate>Sat, 19 May 2012 11:08:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bette</title>
		<link>http://derekdevries.com/2009/04/13/rails-seed-data/comment-page-1/#comment-4464</link>
		<dc:creator>Bette</dc:creator>
		<pubDate>Fri, 29 Apr 2011 18:35:04 +0000</pubDate>
		<guid isPermaLink="false">http://derekdevries.com/?p=72#comment-4464</guid>
		<description>That's way more clever than I was expctieng. Thanks!</description>
		<content:encoded><![CDATA[<p>That&#8217;s way more clever than I was expctieng. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://derekdevries.com/2009/04/13/rails-seed-data/comment-page-1/#comment-3594</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Thu, 13 May 2010 15:23:05 +0000</pubDate>
		<guid isPermaLink="false">http://derekdevries.com/?p=72#comment-3594</guid>
		<description>Thanks for this blog entry. The distinctions between the different categories of data map well to our application. Some of our seed data are driven by external apps in the enterprise, which we fetch through web service calls, exercising care that record IDs are preserved for the same records when we regen the seed files.In the load_fixtures method, did you mean to write (missing NOT operator?):  
if ! table_empty?(table_name) &#124;&#124; always ....  ?</description>
		<content:encoded><![CDATA[<p>Thanks for this blog entry. The distinctions between the different categories of data map well to our application. Some of our seed data are driven by external apps in the enterprise, which we fetch through web service calls, exercising care that record IDs are preserved for the same records when we regen the seed files.In the load_fixtures method, did you mean to write (missing NOT operator?):<br />
if ! table_empty?(table_name) || always &#8230;.  ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Studnev</title>
		<link>http://derekdevries.com/2009/04/13/rails-seed-data/comment-page-1/#comment-2975</link>
		<dc:creator>Studnev</dc:creator>
		<pubDate>Sun, 14 Feb 2010 10:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://derekdevries.com/?p=72#comment-2975</guid>
		<description>For me YAML data with hundred rows does not work.
What i used in FastCSV Gem and placed all data in CSV files. It has additional benefit, that CSV has the first row as metadata, for example:

-- db/seed/data.csv --
product_tag,tag,name
credit_broker,client_age_min,name1
credit_broker,client_age_max,name2

Then place the following code in seeds.rb:

-- db/seeds.rb --
require 'FasterCSV'

FasterCSV.foreach("#{RAILS_ROOT}/db/seed/data.csv" , :headers=&gt;true) do &#124;row&#124;
  print "Created #{row}" if TargetSelector.create_if_notexist(Hash.new.replace row)
end
----

here create_if_notexist gurantees that there will be no errors on duplicate indexes:

-- target_selectors.rb --
  def self.create_if_notexist(params)
    TargetSelector.create(params) if not TargetSelector.find_by_tag_and_product_tag params['tag'], params['product_tag']
  end</description>
		<content:encoded><![CDATA[<p>For me YAML data with hundred rows does not work.<br />
What i used in FastCSV Gem and placed all data in CSV files. It has additional benefit, that CSV has the first row as metadata, for example:</p>
<p>&#8211; db/seed/data.csv &#8211;<br />
product_tag,tag,name<br />
credit_broker,client_age_min,name1<br />
credit_broker,client_age_max,name2</p>
<p>Then place the following code in seeds.rb:</p>
<p>&#8211; db/seeds.rb &#8211;<br />
require &#8216;FasterCSV&#8217;</p>
<p>FasterCSV.foreach(&#8221;#{RAILS_ROOT}/db/seed/data.csv&#8221; , :headers=&gt;true) do |row|<br />
  print &#8220;Created #{row}&#8221; if TargetSelector.create_if_notexist(Hash.new.replace row)<br />
end<br />
&#8212;-</p>
<p>here create_if_notexist gurantees that there will be no errors on duplicate indexes:</p>
<p>&#8211; target_selectors.rb &#8211;<br />
  def self.create_if_notexist(params)<br />
    TargetSelector.create(params) if not TargetSelector.find_by_tag_and_product_tag params['tag'], params['product_tag']<br />
  end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Florian</title>
		<link>http://derekdevries.com/2009/04/13/rails-seed-data/comment-page-1/#comment-2855</link>
		<dc:creator>Florian</dc:creator>
		<pubDate>Wed, 03 Feb 2010 13:25:51 +0000</pubDate>
		<guid isPermaLink="false">http://derekdevries.com/?p=72#comment-2855</guid>
		<description>I just saw that using fixtures is not an issue when you define the id manually in the yml file. So whenever you have an issue with a wonky PK with using fixtures, make sure it is defined explicitly in your seed data.</description>
		<content:encoded><![CDATA[<p>I just saw that using fixtures is not an issue when you define the id manually in the yml file. So whenever you have an issue with a wonky PK with using fixtures, make sure it is defined explicitly in your seed data.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Florian</title>
		<link>http://derekdevries.com/2009/04/13/rails-seed-data/comment-page-1/#comment-2854</link>
		<dc:creator>Florian</dc:creator>
		<pubDate>Wed, 03 Feb 2010 12:42:52 +0000</pubDate>
		<guid isPermaLink="false">http://derekdevries.com/?p=72#comment-2854</guid>
		<description>That is ok as long as you dont want to have your id column to be named as something like '1013200637'.  I don't know why create_fixture doesnt use the provided id field by yaml. I am using Activerecord objects, assign the value field explicitly with one command and then persist it. Which is much more complicated but like that you have validations and you dont have the id issue. Is there any way to fix this id issue with fixtures?</description>
		<content:encoded><![CDATA[<p>That is ok as long as you dont want to have your id column to be named as something like &#8216;1013200637&#8242;.  I don&#8217;t know why create_fixture doesnt use the provided id field by yaml. I am using Activerecord objects, assign the value field explicitly with one command and then persist it. Which is much more complicated but like that you have validations and you dont have the id issue. Is there any way to fix this id issue with fixtures?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: derek</title>
		<link>http://derekdevries.com/2009/04/13/rails-seed-data/comment-page-1/#comment-1562</link>
		<dc:creator>derek</dc:creator>
		<pubDate>Fri, 04 Sep 2009 19:03:13 +0000</pubDate>
		<guid isPermaLink="false">http://derekdevries.com/?p=72#comment-1562</guid>
		<description>Thanks Jorge. I've fixed the example</description>
		<content:encoded><![CDATA[<p>Thanks Jorge. I&#8217;ve fixed the example</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jorge Corona</title>
		<link>http://derekdevries.com/2009/04/13/rails-seed-data/comment-page-1/#comment-1395</link>
		<dc:creator>Jorge Corona</dc:creator>
		<pubDate>Tue, 18 Aug 2009 01:01:05 +0000</pubDate>
		<guid isPermaLink="false">http://derekdevries.com/?p=72#comment-1395</guid>
		<description>You just have a small error on the examples above. You create directories with mkdir named as "data", but the rake task calls "seed".</description>
		<content:encoded><![CDATA[<p>You just have a small error on the examples above. You create directories with mkdir named as &#8220;data&#8221;, but the rake task calls &#8220;seed&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aleks Totic</title>
		<link>http://derekdevries.com/2009/04/13/rails-seed-data/comment-page-1/#comment-1025</link>
		<dc:creator>Aleks Totic</dc:creator>
		<pubDate>Thu, 09 Jul 2009 19:00:34 +0000</pubDate>
		<guid isPermaLink="false">http://derekdevries.com/?p=72#comment-1025</guid>
		<description>Thanks for this entry, very clear. I am just getting started on my 1st rails project. It has about 20 tables, linked in various ways, and seeding it is not trivial. How do you load your always data into the test database?</description>
		<content:encoded><![CDATA[<p>Thanks for this entry, very clear. I am just getting started on my 1st rails project. It has about 20 tables, linked in various ways, and seeding it is not trivial. How do you load your always data into the test database?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

