# == Schema Information
#
# Table name: downloads
#
#  id                :integer          not null, primary key
#  downloadable_id   :integer
#  downloadable_type :string
#  user_id           :integer
#  created_at        :datetime         not null
#  updated_at        :datetime         not null
#

class Download < ApplicationRecord
  # *current_user* download *downloadable*
  include Trackable

  belongs_to :downloadable, polymorphic: true, counter_cache: true
  belongs_to :user

  validates_presence_of :user, :downloadable

  def recipient
    downloadable
  end
end