docbrown/app/models/podcast.rb
Ben Halpern c76abbbdb3
Allow users to follow podcasts (#2690)
* Allow users to follow podcasts

* Only display podcasts user follows

* Add main_color_hex to factory

* Fix podcast test and modify styles

* Fix tests

* Remove weird test
2019-05-04 15:30:40 -04:00

34 lines
558 B
Ruby

class Podcast < ApplicationRecord
has_many :podcast_episodes
mount_uploader :image, ProfileImageUploader
mount_uploader :pattern_image, ProfileImageUploader
validates :main_color_hex, presence: true
after_save :bust_cache
after_create :pull_all_episodes
def path
slug
end
def profile_image_url
image_url
end
def name
title
end
private
def bust_cache
CacheBuster.new.bust("/" + path)
end
def pull_all_episodes
PodcastFeed.new.get_episodes(self)
end
handle_asynchronously :pull_all_episodes
end