Skip to content

Commit 0372363

Browse files
authored
Merge pull request #2259 from davidmillen50/set-belongs-to-required-by-default-to-true
chore: set belongs_to_required_by_default to true in config This is the upcoming default value for this setting, this prepares us for the Rails upgrade.
2 parents f06a3d1 + 896639a commit 0372363

15 files changed

+17
-19
lines changed

app/models/address.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Address < ApplicationRecord
2-
belongs_to :sponsor
2+
belongs_to :sponsor, optional: true
33
end

app/models/attendance_warning.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class AttendanceWarning < ApplicationRecord
22
belongs_to :member
3-
belongs_to :issued_by, class_name: 'Member', foreign_key: 'sent_by_id', inverse_of: false
3+
belongs_to :issued_by, class_name: 'Member', foreign_key: 'sent_by_id', inverse_of: false, optional: true
44

55
scope :last_six_months, -> { where(created_at: 6.months.ago...Time.zone.now) }
66

app/models/auth_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class AuthService < ApplicationRecord
2-
belongs_to :member
2+
belongs_to :member, optional: true
33
validates :uid, uniqueness: { constraint: :provider }
44
end

app/models/ban.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Ban < ApplicationRecord
2-
belongs_to :member
2+
belongs_to :member, optional: true
33
belongs_to :added_by, class_name: 'Member'
44

55
validates :expires_at, :reason, :note, :added_by, presence: true

app/models/contact.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'services/mailing_list'
22
class Contact < ApplicationRecord
3-
belongs_to :sponsor
3+
belongs_to :sponsor, optional: true
44

55
validates :name, :surname, :email, presence: true
66

app/models/event.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Event < ApplicationRecord
88

99
resourcify :permissions, role_cname: 'Permission', role_table_name: :permission
1010

11-
belongs_to :venue, class_name: 'Sponsor'
11+
belongs_to :venue, class_name: 'Sponsor', optional: true
1212
has_many :sponsorships
1313
has_many :sponsors, -> { where('sponsorships.level' => nil) }, through: :sponsorships, source: :sponsor
1414
has_many :bronze_sponsors, -> { where('sponsorships.level' => 'bronze') }, through: :sponsorships, source: :sponsor

app/models/feedback.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Feedback < ApplicationRecord
22
belongs_to :tutorial
33
belongs_to :coach, class_name: 'Member'
4-
belongs_to :workshop
4+
belongs_to :workshop, optional: true
55
has_one :chapter, through: :workshop
66

77
validates :rating, inclusion: { in: 1..5, message: "can't be blank" }

app/models/feedback_request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class FeedbackRequest < ApplicationRecord
22
belongs_to :member
3-
belongs_to :workshop
3+
belongs_to :workshop, optional: true
44

55
validates :member_id, presence: true, uniqueness: { scope: [:workshop] }
66
validates :workshop, presence: true

app/models/invitation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Invitation < ApplicationRecord
33

44
belongs_to :event
55
belongs_to :member
6-
belongs_to :verified_by, class_name: 'Member'
6+
belongs_to :verified_by, class_name: 'Member', optional: true
77

88
validates :event, :member, presence: true
99
validates :member_id, uniqueness: { scope: %i[event_id role] }

app/models/meeting_talk.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class MeetingTalk < ApplicationRecord
2-
belongs_to :speaker, class_name: 'Member'
3-
belongs_to :meeting
2+
belongs_to :speaker, class_name: 'Member', optional: true
3+
belongs_to :meeting, optional: true
44

55
validates :title, :abstract, :speaker, :meeting, presence: true
66

0 commit comments

Comments
 (0)