summaryrefslogtreecommitdiff
path: root/db/seeds/4_beds_and_rafts.rb
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-08-24 20:29:54 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-08-24 20:29:54 +0200
commit52b044d6a4278c229992404ad5801769c2d13363 (patch)
treeb30b34da58f26117c035391d09366b190350b1e3 /db/seeds/4_beds_and_rafts.rb
First commit.
Vive le Castel Peter !
Diffstat (limited to 'db/seeds/4_beds_and_rafts.rb')
-rw-r--r--db/seeds/4_beds_and_rafts.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/db/seeds/4_beds_and_rafts.rb b/db/seeds/4_beds_and_rafts.rb
new file mode 100644
index 0000000..0105260
--- /dev/null
+++ b/db/seeds/4_beds_and_rafts.rb
@@ -0,0 +1,24 @@
+BEDS = 14
+RAFTS = 10
+
+1.upto(BEDS) do |b|
+ bed = Bed.find_or_create_by!(location: b)
+
+ crop_name = case b
+ when 1..2 then "tomatoes"
+ when 3 then "hot peppers"
+ when 4 then "chives"
+ when 5 then "italian basil"
+ when 6..7 then "chinese cabbage"
+ else "lettuce"
+ end
+
+ 1.upto(RAFTS) do |r|
+ raft = bed.rafts.find_or_create_by!(location: r) do |raft|
+ raft.crop = Crop.find_by!(name: crop_name)
+ end
+ end
+end
+
+puts "Beds: #{Bed.count}"
+puts "Rafts: #{Raft.count}"
Copyright 2019--2025 Marius PETER