Matchu
4f564db785
Some important little upgrades but mostly straightforward! Note that there's still a known issue where item searches crash, I was hoping that this was a bug in Rails 4.2 that would be fixed on upgading to 5, but nope, oh well! Also uhh I just got a bit silly and didn't actually mean to go all the way to 5.2 in one go, I had meant to start at 5.0… but tbh the 5.1 and 5.2 changes seem small, and this seems to be working, so. Yeah ok let's roll!
24 lines
529 B
Ruby
24 lines
529 B
Ruby
class DonationFeature < ApplicationRecord
|
|
belongs_to :donation
|
|
belongs_to :outfit
|
|
|
|
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
|