Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
class Song < ActiveRecord::Base
attr_accessible :artist, :artwork, :category, :credits, :title, :track, :year
belongs_to :user
validates_presence_of :user_id
validates_presence_of :title
mount_uploader :track, TrackUploader
after_save :enqueue_track
def track_name
File.basename(track.path || track.filename) if track
end
def enqueue_track
TrackWorker.perform_async(id, key) if key.present?
end
class TrackWorker
include Sidekiq::Worker
def perform(id, key)
song = Song.find(id)
song.key = key
song.remote_track_url = song.track.direct_fog_url(with_path: true)
song.save!
song.update_column(:track_processed, true)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.