diff options
Diffstat (limited to 'app/controllers/beds_controller.rb')
-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." |