seeding 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +27 -1
- data/lib/seeding/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -37,8 +37,34 @@ Example:
|
|
37
37
|
`1.9.3p0 :001 > Seeding::CreateSeed.new.query { Category.all(:order => "name desc", :select => "id, name, country, catgroup") }`
|
38
38
|
|
39
39
|
creates:
|
40
|
+
seeding-Category-604a68a0-c3f4-012f-fcf7-482a14164364.rb
|
41
|
+
|
42
|
+
Which looks basically like this:
|
43
|
+
|
44
|
+
Category.create! :id => 324, :name => 'Zoohandlungen ', :country => 'de', :catgroup => 'Einkaufen'
|
45
|
+
puts "."
|
46
|
+
Category.create! :id => 288, :name => 'Zeitungen und Zeitschriften', :country => 'de', :catgroup => 'Werbung & Medien'
|
47
|
+
puts "."
|
48
|
+
Category.create! :id => 76, :name => 'Zeitarbeit', :country => 'de', :catgroup => 'Bildung & Beruf'
|
49
|
+
puts "."
|
50
|
+
Category.create! :id => 107, :name => 'Zahnmedizin', :country => 'de', :catgroup => 'Gesundheit'
|
51
|
+
puts "."
|
52
|
+
Category.create! :id => 229, :name => 'Yoga ', :country => 'de', :catgroup => 'Beauty & Wellness'
|
53
|
+
puts "."
|
54
|
+
Category.create! :id => 52, :name => 'Wohnungs- und Zimmervermittlung ', :country => 'de', :catgroup => 'Öffentliches & Soziales'
|
55
|
+
|
56
|
+
... and so on....
|
57
|
+
|
58
|
+
The puts "." is pretty lame I admit but it's just nice to see that there are still rows written which is indicated by all these dots. If anything, this is better than writing seeds files by hand:-)
|
59
|
+
|
60
|
+
If you need a lot of data in your seed files from different models,: I recommend to combine them via `cat` or good old copy and paste. Of course you could also iterate over a directory with multiple seed files.
|
61
|
+
|
62
|
+
Once you are satisfied with your seed files just copy them to db/seeds.rb
|
63
|
+
and run:
|
64
|
+
`rake db:seed`
|
65
|
+
|
66
|
+
done!
|
40
67
|
|
41
|
-
|
42
68
|
|
43
69
|
|
44
70
|
|
data/lib/seeding/version.rb
CHANGED