public
Rubygem
Description: Advanced seed data handling for Rails, combining the best practices of several methods together.
Homepage: http://mbleigh.lighthouseapp.com/projects/10223-seed-fu
Clone URL: git://github.com/mbleigh/seed-fu.git
Fixed stupid typo merging errors. Sorry to anyone who used this in the last day 
or two.
mbleigh (author)
Tue Aug 19 06:46:41 -0700 2008
commit  a5c2cfb39c96121e53760c726eccecf1052259c9
tree    74daa434a9657f76911cb16135f2749ac0eddc58
parent  3900e430e7a693690715889ba56909a0401606a0
...
66
67
68
69
70
71
72
73
74
75
76
 
 
 
 
 
 
 
 
 
77
78
79
80
81
82
83
 
 
 
 
 
 
 
84
85
86
...
66
67
68
 
 
 
 
 
 
 
 
69
70
71
72
73
74
75
76
77
78
 
 
 
 
 
 
79
80
81
82
83
84
85
86
87
88
0
@@ -66,21 +66,23 @@ module SeedFu
0
 end
0
 
0
 
0
-# Creates a single record of seed data for use
0
-# with the db:seed rake task. 
0
-# 
0
-# === Parameters
0
-# constraints :: Immutable reference attributes. Defaults to :id
0
-def self.seed(*constraints, &block)
0
-  Seeder.plant(self, *constraints, &block)
0
-end
0
+class ActiveRecord::Base
0
+  # Creates a single record of seed data for use
0
+  # with the db:seed rake task. 
0
+  # 
0
+  # === Parameters
0
+  # constraints :: Immutable reference attributes. Defaults to :id
0
+  def self.seed(*constraints, &block)
0
+    SeedFu::Seeder.plant(self, *constraints, &block)
0
+  end
0
 
0
-def self.seed_many(*constraints)
0
-  seeds = constraints.pop
0
-  seeds.each do |seed_data|
0
-    seed(*constraints) do |s|
0
-      seed_data.each_pair do |k,v|
0
-        s.send "#{k}=", v
0
+  def self.seed_many(*constraints)
0
+    seeds = constraints.pop
0
+    seeds.each do |seed_data|
0
+      seed(*constraints) do |s|
0
+        seed_data.each_pair do |k,v|
0
+          s.send "#{k}=", v
0
+        end
0
       end
0
     end
0
   end
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 Gem::Specification.new do |s|
0
   s.name = 'seed-fu'
0
-  s.version = '0.0.1'
0
+  s.version = '0.0.2'
0
   s.date = '2008-08-16'
0
   
0
   s.summary = "Allows easier database seeding of tables."

Comments