summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
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