From a11140f9e1e7db3905e0a82698ad0c2affe8e525 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 25 Feb 2015 13:42:35 -0600 Subject: [PATCH] stop breaking on donations that delete their outfit --- app/models/donation_feature.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/donation_feature.rb b/app/models/donation_feature.rb index 0d650aa5..b1e9c67c 100644 --- a/app/models/donation_feature.rb +++ b/app/models/donation_feature.rb @@ -7,7 +7,7 @@ class DonationFeature < ActiveRecord::Base delegate :donor_name, to: :donation def as_json(options={}) - {donor_name: donor_name, outfit_image_url: outfit.image.medium.url} + {donor_name: donor_name, outfit_image_url: outfit_image_url} end def outfit_url=(outfit_url) @@ -17,4 +17,8 @@ class DonationFeature < ActiveRecord::Base def outfit_id_present? outfit_id.present? end + + def outfit_image_url + outfit && outfit.image ? outfit.image.medium.url : nil + end end