diff --git a/app/models/donation.rb b/app/models/donation.rb index 74a96837..7bee9df0 100644 --- a/app/models/donation.rb +++ b/app/models/donation.rb @@ -2,7 +2,7 @@ class Donation < ApplicationRecord FEATURE_COST = 500 # in cents = $5.00 belongs_to :campaign - belongs_to :user + belongs_to :user, optional: true has_many :features, class_name: 'DonationFeature' def to_param diff --git a/app/models/donation_feature.rb b/app/models/donation_feature.rb index 2440a8be..ac707c37 100644 --- a/app/models/donation_feature.rb +++ b/app/models/donation_feature.rb @@ -1,6 +1,6 @@ class DonationFeature < ApplicationRecord belongs_to :donation - belongs_to :outfit + belongs_to :outfit, optional: true validates :outfit, presence: true, if: :outfit_id_present? diff --git a/app/models/user.rb b/app/models/user.rb index ac5ecf88..62ddb5e9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,7 +18,7 @@ class User < ApplicationRecord has_many :wanted_items, -> { where(ClosetHanger.arel_table[:owned].eq(false)) }, through: :closet_hangers, source: :item - belongs_to :contact_neopets_connection, class_name: 'NeopetsConnection' + belongs_to :contact_neopets_connection, class_name: 'NeopetsConnection', optional: true scope :top_contributors, -> { order('points DESC').where('points > 0') }