From bae68ed2d137b5d93fdd78e5b5556a2ba9a600e3 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Fri, 29 Aug 2025 15:03:13 +0200 Subject: Realign db seed and crop allocation reset seed. --- app/controllers/beds_controller.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/controllers/beds_controller.rb b/app/controllers/beds_controller.rb index c213978..2e4d94c 100644 --- a/app/controllers/beds_controller.rb +++ b/app/controllers/beds_controller.rb @@ -26,17 +26,22 @@ class BedsController < ApplicationController def reset_seed_crops # mirrors seed logic - tomatoes = Crop.find_by!(name: :tomatoes) - chives = Crop.find_by!(name: :chives) - lettuce = Crop.find_by!(name: :lettuce) + tomatoes = Crop.find_by!(name: "tomatoes") + hot_peppers = Crop.find_by!(name: "hot peppers") + chives = Crop.find_by!(name: "chives") + italian_basil = Crop.find_by!(name: "italian basil") + cabbage_chinese = Crop.find_by!(name: "cabbage, chinese") + lettuce = Crop.find_by!(name: "lettuce") Bed.includes(:rafts).find_each do |bed| - default_crop = - case bed.location - when 1..3 then tomatoes - when 4..7 then chives - else lettuce - end + default_crop = case bed.location + when 1..2 then tomatoes + when 3 then hot_peppers + when 4 then chives + when 5 then italian_basil + when 6..7 then cabbage_chinese + else lettuce + end bed.rafts.update_all(crop_id: default_crop.id) end redirect_back fallback_location: root_path, notice: "Raft crops reset to default seed layout." -- cgit v1.2.3