mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-01-24 09:17:53 -05:00
belongs_to defaults to required. setting some to optional
This commit is contained in:
@@ -17,8 +17,8 @@ class Crop < ApplicationRecord
|
||||
has_many :harvests
|
||||
has_many :plant_parts, -> { uniq.reorder("plant_parts.name") }, through: :harvests
|
||||
belongs_to :creator, class_name: 'Member'
|
||||
belongs_to :requester, class_name: 'Member'
|
||||
belongs_to :parent, class_name: 'Crop'
|
||||
belongs_to :requester, class_name: 'Member', optional: true
|
||||
belongs_to :parent, class_name: 'Crop', optional: true
|
||||
has_many :varieties, class_name: 'Crop', foreign_key: 'parent_id'
|
||||
has_and_belongs_to_many :posts # rubocop:disable Rails/HasAndBelongsToMany
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class Harvest < ApplicationRecord
|
||||
belongs_to :crop
|
||||
belongs_to :owner, class_name: 'Member', counter_cache: true
|
||||
belongs_to :plant_part
|
||||
belongs_to :planting
|
||||
belongs_to :planting, optional: true
|
||||
|
||||
##
|
||||
## Scopes
|
||||
|
||||
@@ -6,7 +6,7 @@ class Post < ApplicationRecord
|
||||
#
|
||||
# Relationships
|
||||
belongs_to :author, class_name: 'Member'
|
||||
belongs_to :forum
|
||||
belongs_to :forum, optional: true
|
||||
has_many :comments, dependent: :destroy
|
||||
has_and_belongs_to_many :crops # rubocop:disable Rails/HasAndBelongsToMany
|
||||
# also has_many notifications, but kinda meaningless to get at them
|
||||
|
||||
Reference in New Issue
Block a user