Skip to content
Snippets Groups Projects
Forked from PortalMEC / portalmec
1205 commits behind the upstream repository.
share.rb 540 B
# == Schema Information
#
# Table name: shares
#
#  id             :integer          not null, primary key
#  shareable_id   :integer
#  shareable_type :string
#  user_id        :integer
#  created_at     :datetime         not null
#  updated_at     :datetime         not null
#

class Share < ApplicationRecord
  # *current_user* shares *shareable*
  include Trackable

  belongs_to :shareable, polymorphic: true, counter_cache: true
  belongs_to :user

  validates_presence_of :user, :shareable
  
  def recipient
    shareable
  end
end