impress/app/models/donation_feature.rb

21 lines
448 B
Ruby
Raw Normal View History

2014-09-09 21:16:02 -07:00
class DonationFeature < ActiveRecord::Base
belongs_to :donation
belongs_to :outfit
validates :outfit, presence: true, if: :outfit_id_present?
2014-09-09 21:16:02 -07:00
2014-09-10 13:38:26 -07:00
delegate :donor_name, to: :donation
def as_json(options={})
{donor_name: donor_name, outfit_image_url: outfit.image.medium.url}
end
2014-09-09 21:16:02 -07:00
def outfit_url=(outfit_url)
self.outfit_id = outfit_url.split('/').last rescue nil
end
def outfit_id_present?
outfit_id.present?
end
2014-09-09 21:16:02 -07:00
end