diff options
author | Marius Peter <marius.peter@tutanota.com> | 2025-08-29 15:03:13 +0200 |
---|---|---|
committer | Marius Peter <marius.peter@tutanota.com> | 2025-08-29 15:03:13 +0200 |
commit | bae68ed2d137b5d93fdd78e5b5556a2ba9a600e3 (patch) | |
tree | 5bfe4023bbeafd8e97be80676625724807048043 | |
parent | 075665c588989ed0decdfb20d83f32b33eed4639 (diff) |
Realign db seed and crop allocation reset seed.
-rw-r--r-- | app/controllers/beds_controller.rb | 23 |
1 files 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." |