Matchu
621a0bc211
I noticed this was stopping changing your default list visibility bc contact neopets connection can't be empty, so I fixed that! And then I just decided to scroll through every `belongs_to` relationship and add optional to the ones that jumped out at me lol
24 lines
545 B
Ruby
24 lines
545 B
Ruby
class DonationFeature < ApplicationRecord
|
|
belongs_to :donation
|
|
belongs_to :outfit, optional: true
|
|
|
|
validates :outfit, presence: true, if: :outfit_id_present?
|
|
|
|
delegate :donor_name, to: :donation
|
|
|
|
def as_json(options={})
|
|
{donor_name: donor_name, outfit_image_url: outfit_image_url}
|
|
end
|
|
|
|
def outfit_url=(outfit_url)
|
|
self.outfit_id = outfit_url.split('/').last rescue nil
|
|
end
|
|
|
|
def outfit_id_present?
|
|
outfit_id.present?
|
|
end
|
|
|
|
def outfit_image_url
|
|
outfit && outfit.image ? outfit.image.medium.url : nil
|
|
end
|
|
end
|