summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-08-29 14:22:37 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-08-29 14:22:37 +0200
commit075665c588989ed0decdfb20d83f32b33eed4639 (patch)
treed9ec78be7338bd51c895b7fb311f081a7c77c45f /app/models
parent52b044d6a4278c229992404ad5801769c2d13363 (diff)
Properly implement bed and raft management logic.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/bed.rb1
-rw-r--r--app/models/raft.rb2
2 files changed, 2 insertions, 1 deletions
diff --git a/app/models/bed.rb b/app/models/bed.rb
index 33eafd2..d41afe6 100644
--- a/app/models/bed.rb
+++ b/app/models/bed.rb
@@ -1,4 +1,5 @@
class Bed < ApplicationRecord
has_many :rafts, -> { order(:location) }, dependent: :destroy
+ accepts_nested_attributes_for :rafts
validates :location, presence: true, uniqueness: true
end
diff --git a/app/models/raft.rb b/app/models/raft.rb
index af52700..3fe5928 100644
--- a/app/models/raft.rb
+++ b/app/models/raft.rb
@@ -1,5 +1,5 @@
class Raft < ApplicationRecord
belongs_to :bed
- belongs_to :crop
+ belongs_to :crop, optional: true
validates :location, presence: true, uniqueness: { scope: :bed_id }
end
Copyright 2019--2025 Marius PETER